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 CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      32 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      195 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      356 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      277 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X