Just one more question

 

This code should give me the Open and Close of the 50th candle in a chart, but actually gives the Open and Close of the 51st candle. Is there a way to get these two points in line with each other. The count of the candle with it's Open and Close?

Thanks!

   
string textE;

   double YOp = iOpen(NULL,PERIOD_D1,50);
   double YCl = iClose(NULL,PERIOD_D1,50);

   
    if(YOp > YCl)
   {textE = "SELL";}

   
   if(YOp < YCl)
   {textE = "BUY";}  

   
   Alert("YOp = ",DoubleToStr(YOp,Digits),"     YCl = ",DoubleToStr(YCl,Digits),"    Candle  50  is a ",textE," candle");
 
 
Yellowbeard:

This code should give me the Open and Close of the 50th candle in a chart, but actually gives the Open and Close of the 51st candle. Is there a way to get these two points in line with each other. The count of the candle with it's Open and Close?

Thanks!

The current candle is number 0
 
Don't know, everything I try only ends up with the candle count and Open and Close of the candle, out of sync by 1.
 
Don't know what? The right most candle is zero. The second from the right is one. The 50th from the right is 49.
 
Yellowbeard:
Don't know, everything I try only ends up with the candle count and Open and Close of the candle, out of sync by 1.
RaptorUK:
The current candle is number 0

The third candle on a chart is . . . 2, 1, 0 . . . . bar number 2 the 50th bar on a chart is bar number 49.
Reason: