Avoid trading days either side of Non Farm Payroll subject to what day of the month Non Farm Payroll lands on

 

Hi

I am trying to code a method to avoid volatility either side of Non Farm Payrol (NFP).

I would like to be able to select to trade or not trade the following.

1. Trade or not Trade NFP. I have this code that seems to work

extern bool NFP_Friday              = true;
if(DayOfWeek() == 5 && Day() < 8 && NFP_Friday==false ) // Lets not Trade NFP

2. Trade or not Trade up to 4 days before NFP. I have this code that seems to work

extern int DaysBeforeNFP            =0; // enter numbers 1 to 4 here
if(DayOfWeek() == DaysBeforeNFP && Day() < 8 && NFP_Friday==false 

Is it possible to ensure that the days before are trading days?

3. I also want to trade or not trade up to the last 5 "trading days" of any month.

Can anyone point me in the right direction for this?

Thanks

Neil

 

HI,

with this code


extern bool NFP_Friday              = true;
if(DayOfWeek() == 5 && Day() < 8 && NFP_Friday==false ) // Lets not Trade NFP


you could have a problem next month  October 2021 when the NFP are not 1.10.2021 but 8.10.2021..

 
riccardo1981 #:

HI,

with this code



you could have a problem next month  October 2021 when the NFP are not 1.10.2021 but 8.10.2021..

 
Ok....got you right.
Reason: