Hi,
I need help for auto order code from Amibroker to IB (Interactive Broker TWS).
?
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();
Thank you
Hanu