Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on 'OnBarUpdate' method on bar 0: Object reference not set to an instance...

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

    Error on 'OnBarUpdate' method on bar 0: Object reference not set to an instance...

    Hi,

    I'm receving the 2 errors below on an indicator that I've created:

    Indicator 'CongestionBoxLite': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.

    Indicator 'DynamicSRCongestionBoxLite': Error on calling 'OnBarUpdate' method on bar 1: 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.

    Code:
    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 1)
    return;
    
    if (Bars.IsFirstBarOfSession)
    {
    
    SRLine[0] = Open[0];
    }
    else if (Close[0] > CongestionBoxLite1.UpperBoundarySeries[0])
    {
    SRLine[0] = CongestionBoxLite1.LowerBoundarySeries[0];
    }
    else if (Close[0] < CongestionBoxLite1.LowerBoundarySeries[0])
    {
    SRLine[0] = CongestionBoxLite1.UpperBoundarySeries[0];
    }
    else if (CurrentBar>0 && SRLine.IsValidDataPointAt(CurrentBar-1))
    {
    SRLine[0] = SRLine[1];
    }

    #2
    Hello AgriTrdr,

    Is CongestionBoxLite an indicator that you have made? The error is coming from that indicator so you would need to debug that indicator in this use case to find out what object was null in its OnBarUpdate method. The DynamicSRCongestionBoxLite also is producing an error so that indicator would also need to be debugged when called in this way.

    ​You can use prints in those indicator to identify which lines are having problems by adding prints between each line and then seeing which is the last print before the error. The code after that print would be related to the problem.

    Comment


      #3
      the congestion box lite I remember did not actually have plots to use in strategies - It only had drawings on the chart

      Is this something that is updated

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      89 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X