Download MetaTrader 5

Cannot get proper value of bars

To add comments, please log in or register
Articles have already helped many traders. Come and read them!
Yong Zheng
128
Yong Zheng 2015.01.25 17:30 

Hello,

I am just programming a sample expert advisor and let it run in strategy expert. but have following problem. I tried both version ( Open[ 0 ] and  iOpen ).

 

sPrice.dOpen   = Open[ 0 ];
sPrice.dClose  = Close[ 0 ];
sPrice.dHigh   = High[ 0 ];
sPrice.dLow    = Low[ 0 ];


sPrice.dOpen   = iOpen( NULL, PERIOD_M15, 0 );
sPrice.dClose  = iClose( NULL, PERIOD_M15, 0 );
sPrice.dHigh   = iHigh( NULL, PERIOD_M15, 0 );
sPrice.dLow    = iLow( NULL, PERIOD_M15, 0 );


Print( "open: ", sPrice.dOpen, " close: ", sPrice.dClose, " high: ", sPrice.dHigh, " low: ", sPrice.dLow );

 

it print out like following

2015.01.25 18:08:27.440 2014.07.21 23:45  TestEA EURUSD,M15: open: 1.35237 close: 1.35237 high: 1.35237 low: 1.35237

2015.01.25 18:08:27.440 2014.07.21 23:30  TestEA EURUSD,M15: open: 1.3523 close: 1.3523 high: 1.3523 low: 1.3523

2015.01.25 18:08:27.440 2014.07.21 23:15  TestEA EURUSD,M15: open: 1.35224 close: 1.35224 high: 1.35224 low: 1.35224

2015.01.25 18:08:27.440 2014.07.21 23:00  TestEA EURUSD,M15: open: 1.35214 close: 1.35214 high: 1.35214 low: 1.35214

2015.01.25 18:08:27.438 2014.07.21 22:45  TestEA EURUSD,M15: open: 1.3522 close: 1.3522 high: 1.3522 low: 1.3522

2015.01.25 18:08:27.437 2014.07.21 22:30  TestEA EURUSD,M15: open: 1.35215 close: 1.35215 high: 1.35215 low: 1.35215

2015.01.25 18:08:27.437 2014.07.21 22:15  TestEA EURUSD,M15: open: 1.35231 close: 1.35231 high: 1.35231 low: 1.35231

2015.01.25 18:08:27.437 2014.07.21 22:00  TestEA EURUSD,M15: open: 1.35217 close: 1.35217 high: 1.35217 low: 1.35217

2015.01.25 18:08:27.434 2014.07.21 21:45  TestEA EURUSD,M15: open: 1.35221 close: 1.35221 high: 1.35221 low: 1.35221

Why are they all the same??? 

whroeder1
14503
whroeder1 2015.01.25 20:23  
JnZn558: Why are they all the same??? 
  1. Post all the relevant code (using SRC.)
  2. You apparently only printing the first tick where O=H=L=C
gadget
100
gadget 2015.01.26 16:58  
The current bar should already carry different values, are you sure you print the correct variables?
To add comments, please log in or register