- Use the Styler in the Editor (Strl+, or Tools => Styler) to 'beautify' your code.
- If you post code please use (and edit your code accordingly) the code button (Alt+S or the code button from the editor header line </>).
- It seems this is MT4 code - it has its own thread a little bit lower...
I fixed the points you mentioned, can you take a look again?
- Thank you :)
- NormalizeDouble is needless as the difference to 'not normalized' close is a lot less than _Point! Read this about it: https://www.mql5.com/en/forum/390336#comment_28182542
- If you want to have a nice printout use DoubleToString(...)!
- The prices on the chart and of iClose (iOpen, iHigh,..) are always 'made of' Bid prices.
- You'd better use 2.0 *_Point as otherwise _Point could be casted to an integer as 2 is an integer.
- Any time OnTick is called X is set to Close[10] so nothing is summed up,read about static variables: https://www.mql5.com/de/docs/basis/variables/static.
- Make sure that the indexing of iClose is the way you want it: https://www.mql5.com/en/docs/series/bufferdirection
Double value doesn't show Normalize digits
- 2022.03.07
- www.mql5.com
Hello Everyone i used a normalize function for a double value but it doesn't show fixed digits in results...
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
Hello, Greeting, I want to change a number according to the changes in the prices of ask and bid. It means that, for example, for every two point change in each of these two ask and bid prices, my number changes by one point, just like what happens in the trail of a position. Can you tell which part of this code has a problem?
void OnTick()
{
X = NormalizeDouble(iClose(_Symbol, 0, 10), _Digits);
if(Ask + 2 * _Point < X)
{
X -= 2 * _Point;
Print("", Ask);
Print("1 ===>>>> X: ", X);
}
if(Bid - 2 * _Point > X)
{
X += 1 * _Point;
Print("", Bid);
Print("2 ===>>>> X: ", X);
}
}