I am running a MTF strategy and I need my order to be cancelled 1 minute before the end of the primary time frame period, I was thinking to use this code, but I was wondering if you have any better suggestions:
primarytimeFrame == 60 min
secondaryTimeFrame == 1 min
if(BarsInProgress == 1)
{
if (longCondition == true)
{
entryOrderLong = EnterLongLimit(1, true, 1, Low[0],"Long");
}
//Cancel long order if not done within 1 minute to the end of primary time frame
if(Times[1][0] >= Times[0][0].AddMinutes(primaryTimeFrame-1) && entryOrderLong != null))
{
CancelOrder(entryOrderLong);
}
}

Comment