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

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.
    Understand the fundamentals of basic strategy creation by developing an actual strategy using the NinjaTrader Strategy Wizard.3:23 Strategy Wizard Overview7:...


    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 quantismo, 04-17-2024, 05:13 PM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            34 views
            0 likes
            Last Post love2code2trade  
            Started by cls71, Today, 04:45 AM
            2 responses
            10 views
            0 likes
            Last Post eDanny
            by eDanny
             
            Started by kulwinder73, Today, 10:31 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X