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 DayTradingDEMON, Today, 07:23 PM
      0 responses
      5 views
      0 likes
      Last Post DayTradingDEMON  
      Started by XXfea, Today, 07:01 PM
      0 responses
      4 views
      0 likes
      Last Post XXfea
      by XXfea
       
      Started by RedPothos, Today, 05:07 PM
      0 responses
      11 views
      0 likes
      Last Post RedPothos  
      Started by JohnZee, Today, 04:14 PM
      0 responses
      7 views
      0 likes
      Last Post JohnZee
      by JohnZee
       
      Started by timmbbo, Today, 04:11 PM
      0 responses
      12 views
      0 likes
      Last Post timmbbo
      by timmbbo
       
      Working...
      X