Hello,
I am seeking confirmation on the OPENTIME instruction.
I am trading the hourly timeframe and I do not want to open new trades after 21.45 or opening a new trades on Saturday or Sunday.
The code I used so far is:
TimeCond = OpenTime <= 214500
DayCond = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5
IF TimeCond and DayCond THEN
cond1 = ……
IF NOT ONMARKET and cond1 THEN
BUY size PERPOINT AT MARKET
SET TARGET $PROFIT (35 * size)
SET STOP $LOSS (35 * size)
ENDIF
ENDIF
Problem = the program opened a trade on Monday at 22.00 – that is exactly what I was trying to avoid (at 22.00 the DFB spread is incredibly wide).
Doing some more digging I understood the OPENTIME instruction returns the opening time of the bar and it does not refer to the opening time of the trade as I mistakenly assumed. Therefore in order to avoid any order at 22.oo and at 23.00 I need to update the code above as follow:
TimeCond = OpenTime <= 204500 OR OpenTime >= 224500
In this way I expect the bar starting at 21.00 and the bar starting at 22.00 to be disregarded and therefore no trades will be taken at 22.00 or 23.00.
Is my interpretation correct?
Thanks very much, Gaby