Download MetaTrader 5

DoubleToStr() is not working in Moving Average value. I want to display the MA value in 5 digits

To add comments, please log in or register
Musngi
299
Musngi  
DoubleToStr() is not working in Moving Average value. I want to display the MA value in 5 digits. 
When I pointed the cursor in MA line the value have 5 digits but when I use the iMA() function to display the value its display 4 digits.
Here's the code:
double m = DoubleToStr(iMA("EURUSDi", PERIOD_M1, 7, 0, MODE_EMA, PRICE_CLOSE, 0), 5);
Print("MA: ", m);
Keith Watford
Moderator
10371
Keith Watford  
double m = DoubleToStr(iMA("EURUSDi", PERIOD_M1, 7, 0, MODE_EMA, PRICE_CLOSE, 0), 5);
Print("MA: ", m);

try

string m = DoubleToStr(iMA("EURUSDi", PERIOD_M1, 7, 0, MODE_EMA, PRICE_CLOSE, 0), 5);
Print("MA: ", m);

.

Musngi
299
Musngi  
GumRai:

try

.

If I need to display the value I need to convert to string then convert it back to double type to calculate then convert it again to string to display the 5 digits??

DoubleToStr() -> StrToDouble()  ->  DoubleToStr()

I want to know if I get the 4 digit it means there's a invisible 5th digits Or I need to convert to string to get the 5th digits then convert it back to double to calculate??

I discovered the double() function to convert the value to double type. Is double() and StrToDouble() are the same?? 

Keith Watford
Moderator
10371
Keith Watford  
Musngi:

If I need to display the value I need to convert to string then convert it back to double type to calculate then convert it again to string to display the 5 digits??

DoubleToStr() -> StrToDouble()  ->  DoubleToStr()


No, of course not, if you want to work with the MA value, get it as a double first then use DoubleToStr() in the Print

   double m=iMA("EURUSDi",PERIOD_M1,7,0,MODE_EMA,PRICE_CLOSE,0);
   Print("MA: ",DoubleToStr(m,5));


Is double() ???  There is no such function as far as I know

Musngi:

I discovered the double() function to convert the value to double type. Is double() and StrToDouble() are the same?? 

To add comments, please log in or register