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

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 algospoke, Today, 06:40 PM
            0 responses
            4 views
            0 likes
            Last Post algospoke  
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            7 views
            0 likes
            Last Post maybeimnotrader  
            Started by quantismo, Today, 05:13 PM
            0 responses
            6 views
            0 likes
            Last Post quantismo  
            Started by AttiM, 02-14-2024, 05:20 PM
            8 responses
            168 views
            0 likes
            Last Post jeronymite  
            Started by cre8able, Today, 04:22 PM
            0 responses
            9 views
            0 likes
            Last Post cre8able  
            Working...
            X