couldn't get nth previous candles open

 

Hi,

I am trying to get nth prev candle's open and display it on the current candle. But my code does the opposite. Puts the current candle's open on nth candle. Couldn't figure out what I am doing wrong.

void start()
  {
   int i, Counted_bars; 

   Counted_bars = IndicatorCounted();
   i=Bars-Counted_bars-1;

   while(i>=0)                
     {       
      double open  = Open[i-InpPricePeriod];

      PriceOExtLineBuffer[i] = open;     
      
      i--;
     }
    
   return;
  }

Files:
indi.png  20 kb
 
mqlvuI am trying to get nth prev candle's o
  1. So do that. Nth previous candle relative to i is i+n
  2. When i is less then InpPricePeriod, you try to access Open[ minus number ] which does not exist. You would know that if you had used strict.

    Always use strict. Fixing the warnings will save you hours of debugging.

Reason: