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>);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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