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.
    JesseNinjaTrader Customer Service

    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 Taddypole, 06-18-2024, 11:58 AM
      4 responses
      92 views
      0 likes
      Last Post music_p13  
      Started by davydhnz, 04-21-2025, 06:39 AM
      2 responses
      29 views
      0 likes
      Last Post davydhnz  
      Started by Mystery, Yesterday, 10:57 PM
      0 responses
      6 views
      0 likes
      Last Post Mystery
      by Mystery
       
      Started by iceman2018, Yesterday, 08:55 PM
      0 responses
      9 views
      0 likes
      Last Post iceman2018  
      Started by mrmccraig, 04-24-2025, 05:13 PM
      4 responses
      38 views
      0 likes
      Last Post mrmccraig  
      Working...
      X