Timeseries Access with five digits ?

 

Hi!

I just get started with MQL4 and at them moment I'm trying to access the timeseries. I wanna ask for the High, Low etc. of a specific bar. I do it like this:


   int i=1;
   int hour_bar=TimeHour(iTime("EURUSD",PERIOD_M1,i));
   int min_bar=TimeMinute(iTime("EURUSD",PERIOD_M1,i));

   Comment("Last bar for EURUSD M1: ",hour_bar, ":", min_bar,", ",  iOpen("EURUSD",PERIOD_M1,i),", ",
                                      iHigh("EURUSD",PERIOD_M1,i),", ",  iLow("EURUSD",PERIOD_M1,i),", ",
                                      iClose("EURUSD",PERIOD_M1,i),", ", iVolume("EURUSD",PERIOD_M1,i));


I have a broker, that works with five digits for EURUSD, i.e. "1.25573". In my comment I only see 4 digits, so i.e. "1.2557". How can I access the accurate data like it is displayed in MetaTrader when I hover over the bar with the mouse?


Thanks in advance!

Alex

 

Alarska, Try:

string iOpen_full_digit = DoubleToString( NormalizeDouble( iOpen("EURUSD",PERIOD_M1,I),Digits+1 ),Digits );

Comment(" iOpen : ", iOpen_full_digit);
regards, cameo
 
Alarska wrote >>

Hi!

I just get started with MQL4 and at them moment I'm trying to access the timeseries. I wanna ask for the High, Low etc. of a specific bar. I do it like this:



I have a broker, that works with five digits for EURUSD, i.e. "1.25573". In my comment I only see 4 digits, so i.e. "1.2557". How can I access the accurate data like it is displayed in MetaTrader when I hover over the bar with the mouse?


Thanks in advance!

Alex


Comments default to printing doubles to only 4 decimal places...you have to convert your doubles into a string containing more than 5 decimal places. Cameo's code does this but I thought you might also want to know why you need to do it.

 
1005phillip:

Comments default to printing doubles to only 4 decimal places...you have to convert your doubles into a string containing more than 5 decimal places. Cameo's code does this but I thought you might also want to know why you need to do it.

Phillip, to my understanding, after point, comments discard last round zero. So if Ask = 1.2500 & Bid = 1.2503; without the string treatment it would Comment out as
"Ask = 1.25 & Bid = 1.2503 " ... Thanks for the explanation though...
 

I should have written "up to" instead of "only" to be all the more clearer.

 
1005phillip:

I should have written "up to" instead of "only" to be all the more clearer.

Hate to nitpick Phillip, but that would still be 'off'. No worries I have my share of mess-up today :).
 

Data of double type output with 4 digits after the decimal point. To output with more precision, use the DoubleToStr() function.

https://docs.mql4.com/common/Comment

 
1005phillip:

Data of double type output with 4 digits after the decimal point. To output with more precision, use the DoubleToStr() function.

https://docs.mql4.com/common/Comment

:)))))))))). I stand corrected. I never used 5 digits platform come to think of it. if I haven't posted, I would still retain my erred 'concept'. Thx.

 

Hey guys,

thanks a lot for the help. I didn't get an email, that there were answers, so I kind of forgot about it. I will try it now! :)

Reason: