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

Backtest data compared to real time SMA question

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

    Backtest data compared to real time SMA question

    I noticed that If I change my dates in the back test it will change which trades my strategy will take. For instance, in my trading strategy I am not taking trades when the 200 MA is too far from price. So if there is a big gap over night and I have set my dates to exclude the overnight session in my back test then the strategy will take the trade because now the SMA is now close to price. However, if I include the previous day - which accounts for the gap in price, then I my strategy doesn't take the trades, because of the difference in price and the 200 SMA. So my question is this how would this strategy perform in real time? Since it uses historical data and real data, my fear is that the SMA wouldn't be calculated correctly and that it would reset daily.

    So if I stopped the strategy at the end of the day and started it again the next morning. Wouldn't it be missing the data it needs to trade correctly? I do have maximum bar lookback set to 256 so I would have thought this would be able to account for this. I may also change my bars required to trade to 200, but wouldn't that just mean if I started my strategy every morning that it would need 200 bars to trade?

    In short, how can I be sure my strategy will properly calculate the SMA to include previous day prices if I restart the strategy.

    Thanks!

    #2
    Hello, thanks for your post. The SMA needs a certain amount of days, so load that many days in the Data Series menu. You can load data based on the date, bar number, or a fixed date range in the data series menu. You can also use Print() in your strategy to see the data being used by the strategy.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      What do you mean by this "so load that many days in the Data Series menu"?

      Comment


        #4
        Hello, thanks for the follow up. It means to load as much data as is needed. A 200 Period SMA needs at least 200 historical bars to calculate, so make sure that at least 200 bars of data are loaded.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        5 responses
        32 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        13 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
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X