Hi,
Id like to modify my code to trade between 2 specific time frames per day; I’d like the system to be active from:
1) 2:30pm – 6pm and;
2) 8:15pm – 830pm.
I’d like to have flexibility to change this of course.
Can anyone help?
Thanks
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 143000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 203000
timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//timeframe (10 minute, updateonclose)
//max orders each day
if intradaybarindex=0 or day<>day[1] then
orderscount=0
endif
allowtrading=orderscount<maxDayOrder and timeenterbefore and timeenterafter and not daysforbiddenentry
Try this one (not tested):
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 143000
timeEnterBefore = time >= noEntryBeforeTime
noEntryBeforeTime2 = 201500
timeEnterBefore2 = time >= noEntryBeforeTime2
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 180000
timeEnterAfter = time < noEntryAfterTime
noEntryAfterTime2 = 203000
timeEnterAfter2 = time < noEntryAfterTime2
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//timeframe (10 minute, updateonclose)
//max orders each day
if intradaybarindex=0 or day<>day[1] then
orderscount=0
endif
allowtrading=orderscount<maxDayOrder and ((timeenterbefore and timeenterafter) or (timeenterbefore2 and timeenterafter2)) and not daysforbiddenentry