Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

News Filter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    News Filter

    I am going to code a news filter but would like some advice on the best way to implement this. I am guessing an indicator that can be called from a strategy, does that sound best?

    So basically using a historical calendar to exclude trading during NFP, FED and possibly other events I will have to code times and dates for these events and set a flag to true at these times.
    i.e. if(ToTime(Time[0]) == 083000){newsFilter == true;}
    and then using something for the actual date of the event.

    From there how do I get flat and exclude the current trade entry based on an upcoming event, i.e. and event that occurs at 8:30 am on Friday (NFP) before that time even if trading on 60 minute timeframe? Specifically looking at ideas pertaining to the times not lining up exactly as I can handle the trade exit and not entering a new trade.

    Ideas are appreciated as I am working on this now as a strategy that avoids the news give very inaccurate performance statistics when testing without filtering these events.

    Cheers - CableTrader007

    #2
    Hello CableTrader007,

    Thank you for your post.

    For real-time you could use DateTime.Now, however in backtesting this would pull the system time instead of a time stamp. So you may wish to add in a secondary time frame to check the Time[0] against, such as a 1 minute bar series.

    To check a certain time before you could use AddMinutes(). For example:
    Code:
    if(ToTime(Time[0].AddMinutes(60)) > = ToTime(83000))
    {
    // current bar timestamp is one hour or less before 8:30 AM
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    12 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X