Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High and Low DataSeries are empty

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

    High and Low DataSeries are empty

    Hello,
    I'm starting to work with Strategies, and in my test, when I run the backtest with 1 minute candles, I've found that High and Low arrays are emtpy, but Time has 5563 elements and it isn't the first candle, CurrentBars[0] is 360.

    I haven't found any relevant information in Help Guides about when or how are filled those arrays.

    Could you point to me how are filled or how to use them?

    Thanks in advance.



    #2
    Hi ruina, thanks for posting.

    The price series arrays are filled automatically. There is a slot index for every historical bar and a new slot for each new bar. This OnBarupdate method should print out data to the output window given you are connected to a data source:

    Code:
    protected override void OnBarUpdate()
    {
      Print(Highs[0][0]);
      Print(Lows[0][0]);
    }
    If this does not resolve, please share the code you are using or a snippet.

    Kind regards,
    -ChrisL

    Comment


      #3
      Hello ChrisL,

      thanks for your fast answer.

      Sorry for my confusion, but... do you need to be connected to run a backtest?

      Another doubt, I've debugged the code, and High/Low are unidimensional arrays, you're using HighS/LowS, then, can I use High/Low and when?

      My code is simple, I want to print a dot in max and min in a hour.

      Code:
      protected override void OnBarUpdate()
      {[INDENT]if (BarsInProgress != 0[/INDENT][INDENT=2]|| CurrentBars[0] < minBarsToTrade[/INDENT][INDENT])
      return;
      
      var now = Time[0];
      if (now.Hour == 8[/INDENT][INDENT=2]&& now.Minute == 59
      && !this.WaitingBreakout)[/INDENT][INDENT]{[/INDENT][INDENT=2]this.WaitingBreakout = true;
      
      this.MaxRange = High[0];
      this.MinRange = Low[0];
      var currentPrice = Close[0];
      var barMax = 0;
      var barMin = 0;
      for (var minute = 59; minute > 0; minute--)
      {[/INDENT][INDENT=3]if (Math.Max(High[minute], this.MaxRange) > this.MaxRange)
      {[/INDENT][INDENT=4]barMax = minute;[/INDENT][INDENT=3]}
      
      if (Math.Min(Low[minute], this.MinRange) < this.MinRange)
      {[/INDENT][INDENT=4]barMin = minute;[/INDENT][INDENT=3]}
      
      this.MaxRange = Math.Max(High[minute], this.MaxRange);
      this.MinRange = Math.Min(Low[minute], this.MinRange);[/INDENT][INDENT=2]}
      [/INDENT][INDENT] [/INDENT][INDENT=2]var today = now.Date.ToShortDateString();
      Log(today + " Max: " + this.MaxRange + " Min: " + this.MinRange, LogLevel.Information);
      
      // Here, the code crash when use Low[] because Low.Count is 0.
      Draw.Dot(this, @"Dot_" + Convert.ToString(CurrentBars[barMax]), false, barMax, (Low[barMax] + (-4 * TickSize)) , Brushes.CadetBlue);
      Draw.Dot(this, @"Dot_" + Convert.ToString(CurrentBars[barMin]), false, barMin, (High[barMin] + (4 * TickSize)) , Brushes.Tomato);[/INDENT][INDENT]}
      
      //... more things[/INDENT]
       }



      Comment


        #4
        Hi ruina, thanks for the follow up.

        Highs[0][0] is the same as using High[0]. We normally use the plural form when working in multi-series scripts.

        You should be connected to a data source to pull the needed historical data, you will need to historical data on your hard drive within the NInjaTrader database otherwise. You can get a demo data connection here:
        Access step-by-step NinjaTrader platform training for desktop, web, and mobile. Explore video tutorials and practical guides to help you confidently use trading tools and features.


        Kind regards,
        -ChrisL

        Comment


          #5
          Hi ChrisL, I had downloaded the data via Tools > Import > Historical Data > Get Market Replay Data, and used it.
          Anyway, I've connected but I have the same issue, but with other Strategies, I've data to replay. I think that is how High/Low works, I missed something.

          Comment


            #6
            Hi ruina, thanks for the follow up.

            Check the Log tab of the control center for any run time errors. The snippet you posted is not waiting for at least 60 bars before processing the for loop. Add this to the top of OnBarUpdate:

            if(CurrentBars[0] < 60)
            return;

            The High and Low arrays should always have values, this can be proven by printing and observing the output window:

            Print(High[0]);
            Print(Low[0]);

            Kind regards,
            -ChrisL

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            43 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X