4 or 5 digits to display

 

Hello



I'm new to MT and also for programming. I opened a demo account and wanted to play around a bit with the expert advisors.

The only thing i wanted is to display is the actual bar's close price. For this i used: Alert(“Close: “,Close[0]);

But it gives me 1.1234 instead of 1.12345.

If i put Alert(“Digits: “,Digits); it gives 5

I would like to use the prices with 5 digits. Can someone help me please? Really sorry for the loser question but i just can't understand.


Thanks in advance and sorry for my bad english!

 
ang3lt:

Hello



I'm new to MT and also for programming. I opened a demo account and wanted to play around a bit with the expert advisors.

The only thing i wanted is to display is the actual bar's close price. For this i used: Alert(“Close: “,Close[0]);

But it gives me 1.1234 instead of 1.12345.

If i put Alert(“Digits: “,Digits); it gives 5

I would like to use the prices with 5 digits. Can someone help me please? Really sorry for the loser question but i just can't understand.


Thanks in advance and sorry for my bad english!

i think you need to convert the double to string first

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

 
ricx:

i think you need to convert the double to string first

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



You are totally right!

Thanks very much for the quick reply on Saturday =)


Cheers

 

ang3lt:

Thanks very much for the quick reply on Saturday

Saturday and Sunday is when people are killing time until the weekend is over and market opens again.


You will run across the same 4 digits problem when using Print(), Comment() and also if you create a custom indicator you will have to manually tell it to show the numbers in 5 digits. It will internally still always use the highest precision for all calculations, it is only a display issue, MT4 uses the 4 digits as a default in many places because they simply forgot to change this (make the number formatting defaults automatically adapt to the broker digits) when all the brokers switched to 5 digits.

 

Try this code:

Alert("Close: ",DoubleToStr(Close[0],Digits));