I'm making a strategy and I'm interested in opening a contrary position if the SL jumps. I'm having several problems:
If I do it manually, I have no way to open the position at the same point where the order closed. It opens the order at the beginning or end of the M5 candle
SubmitOrderUnmanaged(0, orderAction, OrderType.Market, lots);
ordenCompraStop = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, lotes, 0, maxVelaGatillo + TicksEntry * TickSize, sOCO, "CompraStop"); //I get this error Strategy 'Test': Error on calling 'OnBarUpdate' method on bar 45: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart. // If I log, it tells me that there is no information for BarsArray[1] 12:42:40 - [Test.OnBarUpdate] - Create order BUY STOP BarsArray[0].Count: 276 BarsArray[1].Count: 0
I think it's because there is no tick information on older periods.
In this sample, you can see the second order after SL triggers at begin of M5 candle
In this sample, is OK
Is there some kind of order I can use so that if the SL is executed, it automatically opens a counter order?
How can I test this behaviour?
Thanks

Comment