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

Doing backtest with daily values, I am missing last 2 days, why?

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

    Doing backtest with daily values, I am missing last 2 days, why?

    Although the charts show today (5/21)'s closing values, using debug I was able to see that the backtest ended on (5/19). How I can fix this? I would like it to use up to the latest closing value.
    Thanks,
    CP

    #2
    Hello,

    Can you chart the days you speak of? What data feed and instrument is it? Does it happen on more than one instrument (on the chart)?
    DenNinjaTrader Customer Service

    Comment


      #3
      Yes I the values show up on the charts(I cannot attach image), it shows up like this for any stock I have tried. I am using the Yahoo historical connection. For example the following code: Run to 5/22, which shows up on chart. Only prints out closing price of 5/20. The backtest does show that exit on close on the 5/21. And the SMA's are graphed until 5/21. But why isn't OnBarUpdate called on 5/21 and 5/22 data?

      Code:
      Print("Test: " + Instrument.ToString() + ":" + Time[0].ToString() + " Close: " + Closes[0].ToString());
                  if (CrossAbove(SMA(10), SMA(20), 1))
                      EnterLong();
                  else if (CrossBelow(SMA(10), SMA(20), 1))
                      EnterShort();
      ...
      Test: INTC Default:5/18/2010 12:00:00 AM Close: 21.43
      Test: INTC Default:5/19/2010 12:00:00 AM Close: 21.6
      Test: INTC Default:5/20/2010 12:00:00 AM Close: 20.79

      Comment


        #4
        Hello,

        This is most likely because Yahoo doesn't send the end of the day "event" until Monday. So the close for Fri. never shows up until Monday morning. Sorry, there is nothing we can do about it.

        As a workaround, you can use a different data feed:


        Or you could simulate a Friday close for your strategy by checking to see if it is Friday and checking the time, then use the last price given.
        DenNinjaTrader Customer Service

        Comment


          #5
          Ok,
          Is there a way I can get access to the data on the last day that there is data. i.e. the day that "exit on close" transaction takes place? It doesn't seem to go to OnBarUpdate()
          Thanks,
          CP

          Comment


            #6
            Hello,

            Sorry, you are using Yahoo which only has daily data. So you would get this data if you were running the system live and you had CalculateOnBarClose = true. However in a backtest you won't get that data unless you use a multiple time frame set up, which would take intra-day data, which you don't have.

            Sorry, with Yahoo you are limited to daily data only:
            DenNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fitspressoburnfat, Today, 04:25 AM
            0 responses
            2 views
            0 likes
            Last Post fitspressoburnfat  
            Started by Skifree, Today, 03:41 AM
            1 response
            4 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Started by usazencort, Today, 01:16 AM
            0 responses
            1 view
            0 likes
            Last Post usazencort  
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            604 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            23 views
            0 likes
            Last Post xiinteractive  
            Working...
            X