Download MetaTrader 5

Just one more question

To add comments, please log in or register
Paul
526
Paul  

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");
 
Simon Gniadkowski
Moderator
18004
Simon Gniadkowski  
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
Paul
526
Paul  
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.
whroeder1
14785
whroeder1  
Don't know what? The right most candle is zero. The second from the right is one. The 50th from the right is 49.
Simon Gniadkowski
Moderator
18004
Simon Gniadkowski  
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.
To add comments, please log in or register