Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No historical data when starting strategy from chart

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

    No historical data when starting strategy from chart

    When I first started developing a strategy I had a problem that when starting the strategy (from a chart) the strategy would not receive the historical data from the chart; rather, it would start right away with receiving tick data (CalculateOnBarClose = false). The problem just went away and, for the next month, it worked as expected; that is, when the strategy started, it received (via OnBarUpdate) bar-by-bar all the historical data and then started to receive the current tick data after all of the historical bars were loaded. Now, for some reason, the problem is back in that the very 1st item the strategy sees (in OnBarUpdate) is not the most distant historical bar, but rather the current tick. Consequently there is no historical context.

    I have an Indicator version of the software (same as strategy version but the order processing calls are IFDEFed out). Interestingly, when I run it on the same chart as the strategy, it sees all the historical bars from the chart just fine.

    I cannot figure out what I could have done to prevent the strategy from seeing historical bars. I've tried everything from resetting instruments and repairing the database to reinstalling NinjaTrader. So I am kinda at a loss for the moment....any Ideas??? BTW, still running 6.5.1000.17.
    Last edited by smasters; 09-16-2010, 03:16 AM.

    #2
    smasters, are you using the Historical property somewhere in your OnBarUpdate()?

    Comment


      #3
      Historical is a read-only property...you cannot set it. What I need to do is to somehow 'force' NT to at least load X number of bars in the past. I printed out the value of 'Historical' in the 'Initialize' method and it prints as 'True'. However, the behavior was a little different this morning. Now it is loading 43 bars of historical data as opposed 0 bars of historical data (from the same chart that I was using when I posted the thread a few hours ago. This chart has about 800 bars of historical data). The problem is that the strategy needs about 400 bars of historical data to function properly.

      Comment


        #4
        Well with Historical in the OnBarUpdate() you would still determine if it 'see's' historical chart data or not and would just work in realtime going forward then.

        How many bars are you loading your chart with then for the days back setting?

        This will determine how much the strategy - any MinBarsRequired setting you're using when starting the strategy up.

        Also: is this MultiSeries strategy? Is enough data available for all series Add()ed? All series have to fulfill the MinBarsRequired setting in order for the strategy to run.

        Comment


          #5
          I have a minimum of 3 days of bars loaded on the chart before starting the Strategy from the chart, but the Strategy does not consistently see the historical bars. I can easily determine in the Strategy software whether the Strategy does see them or not, but it seems to me that the developer should be able to expect that NinjaTrader would consistently load all the bars on the chart (into the Strategy), but it does not. Again, when I run the same software (with order processing IFDEFed out) as an Indicator, it consistently sees all the historical bars on the chart. Yes, the Strategy does use a 2nd timeframe, but I don't really care about historical bars on the 2nd timeframe, so I haven't checked for historical access to the second timeframe chart.

          There must be a solution to this, because otherwise, an automated trading system using NT Strategies would have to run 'blind' without a historical context. This is analogous to a discretionary trader trading off of a chart but putting a patch over his left eye so that he sees only the bars going forward in time. It makes not sense. And since (I presume) that there are many production trading systems using NT Strategies, there must be a solution to his.

          There are only two possible solutions. The first would be that there is some mechanism for a Strategy to employ that would 'force' all of the historical bars to be loaded when a strategy is started from a chart. This is what happens with an Indicator (I have never seen an Indicator whose results did not show access to all the bars on the chart)...and it's arguably even more important for it to happen with a Strategy. This would be the preferable solution. Does this solution exist? And if not, why would an Indicator see always see all of the chart bars but a Strategy not??

          The second solution would be programatic. If the Strategy software does not see a historical context, then it would programmatically load the required historical bars by calling High[x], Low[x], Open [x], Close[x], where x varies from 1 to the number of historical bars desired. I have not done this yet, but I trust that the bars 'would have' to be there. Otherwise, we're back to square one in that you cannot consistently rely on a Strategy having access to a historical context, which I find hard to believe as it would render the NT Strategy capability as not practical for any automated trading system that requires a historical context. Will this solution work?

          Your thoughts, comments, and answers to my questions are greatly appreciated.

          Comment


            #6
            You should look into the multiseries aspect here. Please let us know the following and we'll have a better picture.
            • Primary series interval
            • Secondary series interval
            • Minimum bars required setting.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Primary - 5000V
              Secondary - 15M
              Min bars required - I have set it from 20-800 and found that I could not see a difference in behavior; therefore, most recently i have just ignored the setting and I believe the default is around 20 or so when starting a strategy.

              Comment


                #8
                smasters, NinjaTrader would defintitely load all the data however MinBarsRequired is important here as it has to be satisfied for all series involved - otherwise the strategy OnBarUpdate() is indeed not called. Please try a higher DaysToLoad amount in combination with a low MinBarsRequired and recheck.

                Comment


                  #9
                  As you suggested, the multiple time frames caused the anomaly. By ensuring that the secondary (and above) time frames have all of the data (time wise) that exist on the chart that you are using as the primary series chart (the one you start the strategy from), then the primaries series chart will load properly and NT will see all of the historical bars (from both the primary and higher series charts). If you are referencing multiple series charts, you can load the higher level series into your database by first (before you run the strategy) opening charts for the specified series. I have found that if you do not do this, results can be kind of unpredictable in that sometimes, historical bars just don't load correctly which potentially can lead to other errors as well along with, perhaps, your logic not functioning properly as the necessary data is missing.

                  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