i run my strategy in a 5 minutes basis, i enter long or short with a limit order, calculateonbarclose=true
i write the code to say, "if the order is not filled during the 5 minutes, keeps it but cancel it after the 3 bar if it is not filled (15 minutes in total)"
but if the entry order is not filled after the 1st 5 minute, it is cancelled...
here my code (as shown on the guide NT7), can you help to tell me what's wrong ?
// Condition buy
if ( entryOrderAchat == null && buycondition)
{
entryOrderAchat = EnterLongLimit(0, true, 1, Close[0], "Buy");
barNumberOfOrderAchat = CurrentBar;
}
// If entryOrder has not been filled within 3 bars, cancel the order.
elseif (entryOrderAchat != null && CurrentBar > barNumberOfOrderAchat + 3)
{
// When entryOrder gets cancelled below in OnOrderUpdate(), it gets replaced with a Market Order via EnterLong()
CancelOrder(entryOrderAchat);
}
Comment