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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      54 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      71 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X