Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

help with bar index error

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

    help with bar index error

    Hi,

    I am trying to draw horizontal lines 1.5 times daily ATR above and below the recent close.

    I am getting the error "Error on calling 'OnBarUpdate' method for indicator 'ATROnChart' on bar 72: Bar index needs to be greater/equal 0"

    I have added a 1440 min data series in the initiatlize procedure with

    Add(PeriodType.Minute, 1440);

    Here is what I have in the onbarupdate procedure..

    Code:
    double upperLimit, lowerLimit;
    			RemoveDrawObject("UpATR");
    			RemoveDrawObject("DownATR");
    			if (CurrentBar < 72)
    				return;
    			upperLimit=Close[0]+ATR(BarsArray[1], 14)[0]*1.5;
    			lowerLimit=Close[0]-ATR(BarsArray[1], 14)[0]*1.5;
    			Print(CurrentBar + ":::" + upperLimit + "::::" + lowerLimit);
    			DrawLine("UpATR", false, Time[1], upperLimit, Time[1].AddDays(15), upperLimit, Color.Orange, DashStyle.Solid, 1);
    			DrawLine("DownATR", false, Time[1], lowerLimit, Time[1].AddDays(15), lowerLimit, Color.Orange, DashStyle.Solid, 1);
    Last edited by Eklavya; 06-29-2010, 10:19 AM.

    #2
    Please try replacing your single series CurrentBar check with this one below and then recheck -

    Code:
     
    if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
    return;

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X