Hello guys.
If I wanted to modify one or more strategies that are on this site by limiting the action timeframe (for example: only trading from Monday to Friday, from 08:30 to 12:00 and from 14:00 to 18:00), how should I proceed with the code?
In other words, (i) is there a standard formula to use (copy and paste), and (ii) in which part of the code should I exactly paste this formula (at the end before the closing formula)?
Thanks in advance.
Edo
There you go:
ONCE startT = 000000 //Starting TIME
ONCE endT = 240000 //Ending TIME
TimeRef = OpenTime //replace with TIME if needed
DayRef = OpenDayOfWeek //replace with DAYOFWEEK if needed
//
td0 = 0 AND DayRef = 0 AND TimeRef >= startT AND TimeRef <= endT //Sun
td1 = 1 AND DayRef = 1 AND TimeRef >= startT AND TimeRef <= endT //Mon
td2 = 1 AND DayRef = 2 AND TimeRef >= startT AND TimeRef <= endT //Tue
td3 = 1 AND DayRef = 3 AND TimeRef >= startT AND TimeRef <= endT //Wed
td4 = 1 AND DayRef = 4 AND TimeRef >= startT AND TimeRef <= endT //Thu
td5 = 1 AND DayRef = 5 AND TimeRef >= startT AND TimeRef <= endT //Fri
td6 = 0 AND DayRef = 6 AND TimeRef >= startT AND TimeRef <= endT //Sat
tdCond = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6
Days are identified from 0 (Sunday) through 6 (Saturday), to disable, say WEDNESDAY, set td3 = 0.
Add tdCond to your entry conditions.