@Dalla, I took care of that with this line:

TimeFrame = 240 / BarPeriod;

Pending orders are always calculated in the H4 timeframe.