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 bortz, 11-06-2023, 08:04 AM
    47 responses
    1,603 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    8 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    4 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    12 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X