I'm running into a problem with canceling managed orders in a multi time frame strategy.
From the primary timeframe I sent an EnterLongStop order (live until cancelled = true) to one minute timeframe.
Now I want it to be cancelled on the next open of my primary timeframe. I used a counter to sent a CancelOrder() after one bar. But then backtests show no more trades. When playing a littel with the code I found that if I set the counter to a huge number (1000) the trades reappear.
If I set live untill canceled to false the order holds for only one minute.
If anyone can help me with this, please see th code below
if (BarsInProgress == 0)
{
if (CurrentBar > barNumberOfOrderL + 5)
{
CancelOrder(entryOrderL);
}
if (CurrentBar > barNumberOfOrderS + 5)
{
CancelOrder(entryOrderS);
}
stopOrderL = ExitLongStop(1, true, DefaultQuantity, updatedstopL, "ExitLong 1min", "LongStopEntry 1min");
stopOrderS = ExitShortStop(1, true, DefaultQuantity, updatedstopS, "ExitShort 1min", "ShortStopEntry 1min");
if ( "My entrylong code")
{
entryOrderL = EnterLongStop(1, true, DefaultQuantity, entrypriceL, "LongStopEntry 1min");
stopOrderL = ExitLongStop(1, true, DefaultQuantity, stoppriceL, "ExitLong 1min", "LongStopEntry 1min");
barNumberOfOrderL = CurrentBar;
}
if ( "My entryshort code"
)
{
entryOrderS = EnterShortStop(1, true, DefaultQuantity, entrypriceS, "ShortStopEntry 1min");
stopOrderS = ExitShortStop(1, true, DefaultQuantity, stoppriceS, "ExitShort 1min", "ShortStopEntry 1min");
barNumberOfOrderS = CurrentBar;
}
}

Comment