Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different Bar Index between BackTesting and Market Replay

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

    Different Bar Index between BackTesting and Market Replay

    Dear support,
    we developed strategy in BackTesting and we noted that index is 0 for current bar, for previus bars is >0 and for next bars is<0. In Market replay we noted that index 0 is null position, to get first bar index is -1 and to get current bar index is -Bars.Count. Is it correct or I am wrong?
    My problem is max and min functions, in back testing MAX(High,9)[0] work fine but in Market Replay no, what can I do? We are c# developers and we integrated excel from Ninja script, is there a possibility to manage a form from your script? Our problems are:
    1) Initialize function is called one or more times evenif strategy is not used
    2) There isn't event to know if the strategy is closed/unload/dispose, so we can't unload all our variables (for example a timer)

    Very Thanks for you support

    #2
    a) your understanding of the bar indexing is correct. It works the same realtime, historical and in replay mode.
    b) NinjaScript consultants are available to help program your custom indicators/strategies or to help our users throughout their learning curve. Additional information is located here - http://www.ninjatrader.com/webnew/pa...injaScript.htm

    Comment


      #3
      Thanks,
      In my strategy I use MAX(High,9)[0] function.
      Activating Market Replay Connection, Chart and my Strategy, I note when strategy process Max function, the following code is not interpreted.

      Regards

      Comment


        #4
        Please debug your strategy e.g. by following our educational resource here: http://www.ninjatrader-support.com/v...ead.php?t=3418

        Comment


          #5
          How about adding

          if (CurrentBar < 9) return;

          before the MAX(High,9)[0] function?

          It sounds like this works differently for the Market Replay vs Backtesting. Could the setting of "Min. bars required" be different?

          Best regards,

          KBJ

          Comment


            #6
            Hi,
            no Min bars required is the same..
            I think I solve the problem, I manage data in a procedure that was call from a timer (not from your OnBarUpdate), so your sistem can't know in this moment which is the effective position (index 0) and MAX or MIN go in error status. I replicate with 2 my functions Get_Max and Get_Min your MAX and MIN and strategy works..
            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 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