The code that is causing the issue is in OnBarUpdate and it is when I am trying to cancel any unfilled Entry orders and then reset to null in order for it to prepare for the next trading day.
Here is the code:
if (ToTime(Time[0]) >= ToTime(removeOrderHr, removeOrderMin,0)
&& LongEntry != null)
{
CancelOrder(LongEntry);
LongEntry = null;
}
The problem that I am running into is that LongEntry is also being reset to null when a LongEntry trade is currently active.
Here is the goal:
BUT, if LongEntry does not trigger and get filled before a certain time of day, then cancel LongEntry and reset it to null.
I do have code in OnExecution to say to reset it to null when the LongStop and/or LongLimit are executed. Here is that code:
if ((LongStop != null
|| LongTarget != null)
&& (LongStop == execution.Order
|| LongTarget == execution.Order))
{
LongEntry = null;
}
How can I reset LongEntry to null when the order is cancelled without resetting it every single day if the trade is still in play? So far, I am not able to come up with a workable idea.
Thank you for your help

Comment