Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Filter in Market Replay

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

    Time Filter in Market Replay

    I can't get Market Replay to recognize a time filter that works fine in live trading. Is that just the way it is with Market Replay or can I achieve some success by refining my coding?
    I want to leave the Trading Hours settings alone so that I don't lose bars on my chart.

    #2
    Hello Doctor JR,

    As this pertains to NinjaScript Strategy Development, I have moved this thread from the NinjaTrader 7 Platform Technical Support section of the forums to the NinjaTrader 7 Strategy Development section of the forums.

    This would be something controlled in the logic of the script.

    Below is a link to a video of setting up a time filter in the Strategy Wizard.


    And a link to the reference sample that can be opened in the NinjaScript Editor.


    Also, use prints to ensure the conditions are evaluating as true when expected, and enable TraceOrders to see if orders are being ignored or cancelled.
    Below is a link to a forum post that demonstrates using prints to understand behavior.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Can you show us your code?

      I think you are talking about the 'time warp' effects of what Market Replay
      does to the bar close datetime stamps in the Time series for all the candle
      sticks on the chart. This isn't usually an issue, but it really depends on how
      you coded your time filter.

      If your strategy is intended to be Market Replay compatible, you should not
      use DateTime.Now, since it is not time-warped.

      Using DateTime.Now with Market Replay can introduce serious bugs, perhaps
      this is part of your underlying issue?

      But, fear not, there is a solution for that.

      If you're using DateTime.Now in your strategy, take a look at @BarTimer.cs.

      In there you will find a special 'Now' property that returns a properly time
      warped 'current time' value, just like the real 'DateTime.Now' does.

      Copy that 'Now' code intact to your strategy, leaving it as a property.

      My point is: using regular 'DateTime.Now' with Market Replay is prone to
      cause you bugs and headaches. So, if you do need the correct 'current time'
      even when running Market Replay, use 'Now' instead.

      That is, change all occurrences of 'DateTime.Now' to just 'Now'.

      Good luck!

      Comment


        #4
        The issue discussed in your 2nd post is the kind of info I believe I need. Thanks for the feedback.

        Market Replay is more than just time-warped. Ha ha.

        Comment


          #5
          Originally posted by Doctor JR View Post
          The issue discussed in your 2nd post is the kind of info I believe I need.
          Huh?
          What 2nd post?
          Neither Chelsea nor I have posted twice in this thread ...

          Well, ok, ya got me, this post is my 2nd post.
          Heheh ..

          See the posting number '#n' in the upper right corner?
          Um, so which posting number was most useful?

          Oh, and see that thumbs-up 'Like' button in the lower right corner?
          Click that Like button for postings (no matter how old) that you
          find helpful.

          They send smiles to the faces of guys like me.
          Yep, still trying to get to a million.
          Something about a new car, I hear ...


          Comment


            #6
            I liked both but the 2nd post more so. Thanks again.​

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            557 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X