Code for avoiding the NFP

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #126849 quote
    nonetheless
    Participant
    Master

    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
    #126851 quote
    Francesco
    Participant
    Veteran

    Try this

    If Day<8 and DayOfWeek=5 then
     Nfp=1
    Else
     Nfp=0
    Endif
    nonetheless thanked this post
    #126855 quote
    nonetheless
    Participant
    Master

    Ottima! I assume you mean to define the Nfp time elsewhere, in addition to this?

    #126858 quote
    Francesco
    Participant
    Veteran

    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
    #126862 quote
    nonetheless
    Participant
    Master

    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!

    #126876 quote
    Francesco
    Participant
    Veteran

    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

    #126881 quote
    nonetheless
    Participant
    Master

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Code for avoiding the NFP


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by nonetheless
5 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/19/2020
Status: Active
Attachments: No files
Logo Logo
Loading...