If I wanted to suspend a bot before and after the Non-farm Payroll announcement each month, would the following suffice?
The dates are correct for the coming months, but I don’t know how far in advance they are published. Is there any way to specify the first friday of each month indefinitely?
//avoiding NFP (where Ctime is an entry condition)
if DATE[20200508] and time >= 130000 and time <140000 then
Ctime = 0
endif
if DATE[20200605] and time >= 130000 and time <140000 then
Ctime = 0
endif
if DATE[20200702] and time >= 130000 and time <140000 then
Ctime = 0
endif
Try this
If Day<8 and DayOfWeek=5 then
Nfp=1
Else
Nfp=0
Endif
Ottima! I assume you mean to define the Nfp time elsewhere, in addition to this?
Maybe you can try to add the time range there (used your times)
noEntryBefore = 140000
timeEnterBefore = time > noEntryBeforeTime
noEntryAfter = 130000
timeEnterAfter = time < noEntryAfterTime
If Day<8 and DayOfWeek=5 and timEnterBefore and timeEnterAfter then
Nfp=1
Else
Nfp=0
Endif
Yes, something like that should work, with Nfp as an entry condition.
“If Day<8 and DayOfWeek=5″ is the crucial part that I couldn’t get my head around. Should work in the majority of cases although I just saw that this year the December figures weren’t released until Jan 10. Apart from that it should almost always be Day<8
Thanks!
Well otherwise in order to avoid this, you can go maybe 1 time per year on the calendar, check and put in the code manually all the Fridays to exclude from the trading strategy
Yeah, as far as I can see the dates are published for the whole of each calendar year so doing it manually wouldn’t involve too much effort. Prob the only way to be sure of catching it every month.
Not such an issue with longer TFs but the wild movements that usually occur could wreak havoc with short TF scalping bots.