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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    29 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    17 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    15 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X