Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical - Issue With The Historical Property

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

    Historical - Issue With The Historical Property

    Hello Support,

    Thank you for your great support as always.

    I am encountering a very strange issue in my strategy. The problem lies with the Days to Load parameter & the Historical property.

    When i dont have enough data available through the Days to Load property, the historical data that comes in to the strategy's OnBarUpdate() method does not have the Historical property set to true. Thus all my checks for historical data fails and the main core logic of the strategy starts to execute. Is this a known issue or am i doing something wrong?

    Thanks
    Umer

    #2
    Hi Umer, thanks for the post - is this a single or multi series strategy you're working with in this context?

    Comment


      #3
      Hello Bertrand,

      I am working with multiple dataseries. But, i do all my calculations on the primary timeseries. So:

      Code:
      if(BarsInProgress != 0)
      {
      	return;
      }
      is used at the very start of my OnBarUpdate() method.

      Comment


        #4
        Thanks. Yes, but in this case I would expect your outcome seen unfortunately as you would need to ensure the BarsRequired is satisfied for all series.

        Comment


          #5
          Ok, so here is what i am trying to do, and it is becoming increasingly frustrating because NinjaTrader is behaving pretty inconsistently.

          I need to get the data from the first bar of the day. So i am trying to use the following piece of code. FYI: there are multiple time-series in my strategy. Just for example, suppose that we have added 10 minute, 60 minute & 120 minute time-series in addition to the primary 1 minute timeseries.

          Code:
          protected override void OnBarUpdate()
          {
          	if(BarsInProgress != 0)
          	{
          		return;
          	}
          	
          	if(Time[0] < _currentTime)		//To Check if the current bar is a historical bar or not
          	{
          		if(_currentTime.Date == Time[0].Date)		//To check if the bar is from today
          		{
          			if(BarsArray[1].FirstBarOfSession)		//To check if the current bar is first in the session
          			{
          				_ema = EMA(BarsArray[1], 20)[0];
          				_high = Highs[1][0];
          				_low = Lows[1][0];
          			}
          		}
          		return;
          	}
          	
          	//Rest of the code
          }
          The code has been commented in order to make it self explanatory. Now the problem here is that upto Friday, the above code was running with days to load = 20. And now it is not working the way it should and is giving wrong values. It returns the value of the 10 minute bar 20 days from today rather than giving the 1st 10 min bar of today.

          Can you please explain somethings here:

          1. What exactly does days to load do? Does it load the specified number of bars into the default bar data holding arrays of NinjaTrader?
          2. Does running this only for the primary dataseries make any difference? Is that causing the problem?

          Please advise on this.

          Thanks
          Umer

          Comment


            #6
            Umer, DaysToLoad determines how much data is being loaded onto your chart for all all series, since the primary series will set this value as well for all added series. However when reloading data for the added series would not be reloaded (known limitation unfortunately), it seems you're running into this scenario working your code from BIP == 1. Would you see the same outcome if the added series are manually added to your chart from which you apply the script?

            Comment


              #7
              Added data series manually is just not an option with us. The thing i dont understand is that when i increase the Days to Load to lets say 50, it starts to work just fine.

              Comment


                #8
                What BarsRequired are you running with? The default value of 20?

                Comment


                  #9
                  It is running with 20.

                  Comment


                    #10
                    Ok, then if you only want to load for example with 20 Days, please lower the BarsRequired to let's say 5 - would you get the correct outcome then?

                    Comment


                      #11
                      It worked. Thank you for the help.

                      But can you please tell me what the reason is behind this?

                      Thanks
                      Umer

                      Comment


                        #12
                        Sure, all series have to fullfill the BarsRequired before OnBarUpdate() is normally processed, with your Days to load to 20 and BarsRequired at this value > it did not happen, thus giving you an unexpected outcome. Now you've lowered BarsRequired and it can be easier fullfilled.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        639 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        366 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        107 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        569 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        572 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X