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

Bar referencing back testing vs forward testing

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

    Bar referencing back testing vs forward testing

    A couple of questions regarding taking some strategies live/forward testing.

    Strategies are set to OnEachTick.

    When referencing a bar index on multi-timeframe strategies, Lows[1][0] in back test is referencing the last closed bar of data series 1. When going live, I assume this will need to be altered to Lows[1][1]?

    Similarly, referencing MIN(low,3)[1] in back testing will turn into MIN(low,3)[2] on live?

    Also, I'm assuming the setting for slippage (which I have set for back testing) doesn't apply when forward testing with live data? Or do I have to set slippage to 0?

    Lastly, is there some best practice for automatically altering these values when backtesting/forward testing so as to not have to manually change them every time I switch between the two modes?

    #2
    Hello pmn100,

    Thanks for your post.

    Correct, your references would need to shift when going from State.Historical to State.Realtime if you are using Calculate.OnEachTick.

    Slippage applies only to the historical trades so no need to do anything there.

    You could use State.Realtime to configure an "offset" value. For example if (State==State.Realtime) offset = 1; where offset is an int that is initialized to 0.
    thus: Lows[1][offset] would work in both arrangements.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response. So I'd set "offset" in the State.SetDefaults to 0 and then to 1 in State.Realtime? Is it possible to add this offset to current bar index values rather than replacing like in your example?

      i.e. Lows[1][0+offset] Just that some bars that are current referencing [1] would need to go to [2] etc.

      Sorry not at my computer to test right now.

      Comment


        #4
        Hello pmn100,

        Thanks for your reply.

        You can check for the state in the OnBarUpdate() and then adjust the offset as you wish. (This was my thinking when I wrote checking if (state==...)).
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        4 responses
        31 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X