Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

error message barago or barindex?

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

    error message barago or barindex?

    Hello,

    I have an error message:

    Indicator 'NEWSDBA': Error on calling 'OnRender' method on bar 275: Sequence contains no elements

    What sequence are they talking about and is it barago 275 or barindex 275?

    TY

    #2
    Hi Frank, thanks for writing in.

    This is referencing the bar index 275. Searching the "Sequence contains no elements", this seems to be an issue related to LINQ, or possibly something with custom SharpDX code.

    Best regards,
    -ChrisL

    Comment


      #3
      ChrisL,

      You were right about LINQ, it was

      [/CODE]IEnumerable<double> doubles =
      Enumerable.Repeat(avg, 1);
      [/CODE]

      the cultprit.
      Now i tried to make it manually with for loop but if i iterate 10 i end up with that error:

      Indicator 'NEWSDBA': Error on calling 'OnRender' method on bar 638: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

      If i itererate 1 its fine.


      Code:
      var listavg = new List<double>();
      listavg.Add(avg);
      
      
      for(int x = 0; x < 10; x++)
      {
      listv.Add(listavg[x]);
      
      }
      foreach (var item in listavg)
      {
      Print("avg"+item);
      
      }
      Any pointers?

      TY

      Comment


        #4
        Hi Frank, thanks for your reply.

        The listavg probably does not have enough elements to iterate over. You are only adding one element to the list in this snippet, so it would only have listavg[0].

        Best regards,
        -ChrisL

        Comment


          #5
          Hello Chris,

          I switch the chart from ES09-21 back to ES06-21, where there are no gap between today and yesterday, and suddenly indicator start working.

          Can it be that no element in the sequence is related to the absence of data in the gap between 5pm and 6pm?

          TY

          Comment


            #6
            Hi Frank, thanks for your reply.

            I could not say without more context. All I can see is the script is accessing an invalid index in a for loop from OnRender.

            Best regards,
            -ChrisL

            Comment


              #7
              Chris,

              Invalid index, can you be more specific?

              I made some change:
              Eliminated the Enumerable.Repeat. Still get the Sequence contains no elements
              avg is value number inserted in listavg that is connected to listv. The avg value is repeated 30 times. So there is always one element in avglist. Its the average volume from the bars in the chart.

              Code:
              var listm = new List<double>();
              listm.Add(Close.GetValueAt(CurrentBar));
              
              var listavg = new List<double>();
              
              for(int z = 0; z < 30; z++)
              {
              
              
              fibo2 = (listm[z] - lowPrice0) / (Ncma - lowPrice0);
              
              Print("num"+listm[z]);
              
              
              
              lists.AddRange(listm);
              foreach (var item in lists)
              {
              
              }
              
              
              listavg.Add(avg);
              
              listv.Add(listavg[z]);
              
              
              
              
              foreach (var item in listv)
              {
              Print("avg"+item);
              
              }
              ty

              Comment


                #8
                Hi Frank, thanks for your reply.

                This is more of a C# related issue with custom code. This is not coming from the underlying framework providing the bar data. You will need to use Visual Studio to break at the exception, this will let you see all values and indexes where the error occurred:
                https://ninjatrader.com/support/help..._debugging.htm

                Best regards,
                -ChrisL

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                580 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                336 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X