Download MetaTrader 5
To add comments, please log in or register
Take active part in the life of the community. Improve your rating!
Paul
529
Paul 2014.02.27 19:27 

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
17962
Simon Gniadkowski 2014.02.27 19:30  
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
529
Paul 2014.02.27 22:42  
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
13593
whroeder1 2014.02.27 22:49  
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
17962
Simon Gniadkowski 2014.02.27 22:51  
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