Working with StringFormat() & _Digits
TheHonestPrussian:
Morning all,
So I'm working with StringFormat() and wanting to pass various double figures (i.e. prices, moving averages etc) into a string format. I know how StringFormat() works in MQL4 except how to accommodate for 5 an 3 decimal place prices.
I have the following:
The MA_Period is an Int value, but how can I not hardcode the number of decimal places on the floating price (%0.5f or %0.3f)?
I have read the Help material but it's not particularly helpful.
Many thanks
Morning all,
So I'm working with StringFormat() and wanting to pass various double figures (i.e. prices, moving averages etc) into a string format. I know how StringFormat() works in MQL4 except how to accommodate for 5 an 3 decimal place prices.
I have the following:
The MA_Period is an Int value, but how can I not hardcode the number of decimal places on the floating price (%0.5f or %0.3f)?
I have read the Help material but it's not particularly helpful.
Many thanks
You have to do that with DoubleToString
TheHonestPrussian: but how can I not hardcode the number of decimal places on the floating price (%0.5f or %0.3f)?
The asterisk (*) specifying width, was reported broken; so you need to do it yourself.
string format = stringFormat("Moving Average: %%d %%0.%df ", _Digits);
StringFormat(format,<MA_Period>, <MA_Price>);
So I'm working with StringFormat() and wanting to pass various double figures (i.e. prices, moving averages etc) into a string format. I know how StringFormat() works in MQL4 except how to accommodate for 5 an 3 decimal place prices.
I have the following:
StringFormat("Moving Average: %d %0.5f ",<MA_Period>, <MA_Price>);The MA_Period is an Int value, but how can I not hardcode the number of decimal places on the floating price (%0.5f or %0.3f)?I have read the Help material but it's not particularly helpful.
Many thanks