Keyboard Shortcuts
Likes
Search
IB Amibroker auto order
Hi, ? I have created my code in Amibroker based on my own strategy and tested in live for accurate results. The strategy is working well. I am trying to auto order (Buy/Stop loss/Exit) based on the strategy using the below code but not working. I have created the below code for placing orders but only Buy trade is executing and corresponding sell is not executing when the price hit target. I request you to help me. _SECTION_BEGIN("Order"); if(LastValue( Buy )) { ibc = GetTradingInterface("IB"); // check if we are connected OK if( ibc.IsConnected() ) { if( ibc.GetPositionSize( Name() ) == 0 ) { parentID = ibc.Placeorder(Name(), "Buy", 1, "MKT", 0, 0, "Day", False); ibc.Placeorder( Name(), "Sell", 1, "LMT", brd1, 0, "Day", False, 1, "", parentID); ibc.Placeorder( Name(), "Sell", 1, "STP", (bpd), (bpd), "Day", True, 1, "", parentID); } } } _SECTION_END(); |
¿ªÔÆÌåÓýHanu ? Please don't pester members. They will help if they can. If no-one helps, it's probably because they can't. ? Why might they not be able to help here? Well, perhaps because you're using the Amibroker interface and we don't know how similar it is to the 'native' IB APIs (which is what this group is all about). ? For example, to make a bracket order using the IB APIs, you have to set the 'transmit' flag to false for all the orders in the bracket except for the last one. It's not clear from your code whether you've done that, or whether the AMibroker API provides a mechanism for doing this. ? In any case, you really should be able to solve this yourself: are the target and stop-loss orders visible in TWS? (If you don't know because you're using the Gateway, then use TWS instead so you can see what's going on.) If they are visible, are they waiting for the user to click 'transmit'? If not, are the prices correct (that's entirely your problem to fix)? If they are, then what is the status of the orders (which you can easily see in TWS)? And so on¡ ? In short, you really didn't provide the kind of information that could enable someone to help you, and if you had taken steps to find it you quite possibly would have solved the whole problem yourself. ? There is example code for creating a bracket order in IB's documentation at . ? Finally, if you're still stuck, why not ask this question on the Amibroker forum? ? Richard King Group Owner and Moderator ? |