I would like to submit a limited short and long order at the same time and use profit target and stop loss to generate OCO trade for IB. Below is the sample code. Is that correct and possible to do it this way. The result I want is if the limit long order fill then the limit short will be cancel and use the preset profit target and stop loss to guide the trade and vice versa for the limit short order.
Also, if use IB handle the realtime OCO trade. Do I need to resubmit the limit order everytime when calling the OnBarUpdate().
protectedoverridevoid Initialize()
{
SetProfitTarget("", CalculationMode.Ticks, 50)
SetStopLoss("", CalculationMode.Ticks, 50, false)
CalculateOnBarClose = false;
}
protectedoverridevoid OnBarUpdate()
If (condition==true)
{
EnterLongLimit(1,18100)
EnterShortLimit(1,18000)
}
Comment