I have written a prototype code but can’t get around a sticky point . . .
When a long entry order fills, the OnExecution method submits P/L target orders:
ExitLongStop( BarsInProgress, true, execution.Quantity, execution.Price - 5 * TickSize, @"ExitLongStop_2", @"" );
ExitLongLimit( BarsInProgress, true, execution.Quantity, execution.Price + 5 * TickSize, @"ExitLongLimit_2", @"" );
Then OnBarUpdate does the following:
ExitLongStop( Close[ 0 ] - 4 * TickSize, @"ExitLongStop_1", @"" );
The target orders have to be submitted explicitly vs. using SetStopLoss and SetProfitTarget as otherwise the "ExitLongStop_1" order would be ignored. Wondering why?
Now, the sticky point. In OnBarUpdate, instead of exiting via ExitLongStop I want to reverse the position with EnterShortStop with the same stop price. I would expect that this would result in the same stop order being sent to the brokerage with the only difference being double quantity. But the call to the EnterShortStop method is ignored. The best solution I have in mind is to call EnterShort when the "ExitLongStop_1" order fills but that’s a bad solution.
I would appreciate any ideas.
Thanks
Yuriy

Comment