I have an strategy calculate OnBarClose and order entries with bool isLiveUntilCancelled true.
I have these lines in OnBarUpdateSection to cancel them if prices goes up or go down a distance before execution (variables myEntryShortCancelPrice and myEntryLongCancelPrice.
if (entryShortOrder != null
&& (Low[0] < myEntryShortCancelPrice))
{
CancelOrder(entryShortOrder);
}
if (entryLongOrder != null
&& (High[0] < myEntryLongCancelPrice))
{
CancelOrder(entryShortOrder);
}
There are lot of entries that are ordered and cancelled in the same moment. I guess the reason is that Highs or Lows of entry conditions bars are above or below my variables level to cancel, but that is previous than my order...
Have you got any idea or example to solve that issue? Maybe adding something to "entryLongOrder != null" or "entryShortOrder != null"?
Thanks in advanced
Comment