Rounding is not working

 
I checked with MathRound, NormalizeDouble and Round. Nothing works. I want to round my AccountEquity. How?
int OnInit()
  {
//--- indicator buffers mapping
   Comment(StringFormat("Equity is %f", AccountEquity()));
   NormalizeDouble(AccountEquity(),1);
//---
   return(INIT_SUCCEEDED);
  }
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
 
No, you do not want to round.

You want to limit the output.

   Comment(StringFormat("Equity is %.2f", AccountEquity()));
 
Dominik Christian Egert #:
No, you do not want to round.

You want to limit the output.

Got you. Thanks.

 
IgorFX Trading: I checked with MathRound, NormalizeDouble and Round. Nothing works. I want to round my AccountEquity. How?

Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)

 
William Roeder #:

Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)

Yes. I love these complete posts where everything is extensively explained.




 
William Roeder #:

Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)

I will use float or double. Why do I need to know how numbers are stored in memory?

 
IgorFX Trading #: I will use float or double. Why do I need to know how numbers are stored in memory?

Because ignorance is dangerous and can cause you to write bad code, and in the case of trading, cause you to lose money.

When you understand something it is easier to write proper code with less errors, and be able to understand the reason why. And when something goes wrong, it will be easier to fix.

 
IgorFX Trading #: Why do I need to know how numbers are stored in memory?

Because your ignorance caused your problem.

 
Fernando Carreiro #:

Because ignorance is dangerous and can cause you to write bad code, and in the case of trading, cause you to lose money.

When you understand something it is easier to write proper code with less errors, and be able to understand the reason why. And when something goes wrong, it will be easier to fix.

I just confused the concepts of "format" and "round" and had no idea what "NormalizeDouble" was at all. I just trusted some MQL programmer guru on YouTube and started practicing. Understand me. I program for 1 week.
I'll have to hang out on mql5.com more rarely and reduce my ignorance.  
 Thanks for answers. Still didn't get what floating-point is and why I needed this concept in that code ;) 

You can explain everything in a simple way that a five-year-old child will understand, but for some reason you use the most complex explanation or the words "ignorant" when it is already clear, instead of understanding it as characteristic of a person who does not distinguish between Round and NormalizeDouble .


Where should I go to study instead of mql5.com? It's very difficult here. 
 
IgorFX Trading #: I just confused the concepts of "format" and "round" and had no idea what "NormalizeDouble" was at all. I just trusted some MQL programmer guru and started practicing. Understand me. I program for 1 week.
I'll have to hang out on mql5.com often and reduce my ignorance.  
 Thanks for answers. But still didn't get what floating-point is and why I needed this concept in that code ;) 

You can explain everything in a simple way that a five-year-old child will understand, but for some reason you use the most complex explanation or the words "uneducated" when it is already clear, instead of understanding it as characteristic of a person who does not distinguish between Round and NormalizeDouble. Where should I go to study instead of mql5.com? It's very difficult here.

According to your profile, you are from Russia. If it is easier for you to learn in your language, then there is the both the Russian forum as well as Russian documentation.

 
IgorFX Trading #:
I just confused the concepts of "format" and "round" and had no idea what "NormalizeDouble" was at all. I just trusted some MQL programmer guru on YouTube and started practicing. Understand me. I program for 1 week.
I'll have to hang out on mql5.com more rarely and reduce my ignorance.  
 Thanks for answers. Still didn't get what floating-point is and why I needed this concept in that code ;) 

You can explain everything in a simple way that a five-year-old child will understand, but for some reason you use the most complex explanation or the words "ignorant" when it is already clear, instead of understanding it as characteristic of a person who does not distinguish between Round and NormalizeDouble .


Where should I go to study instead of mql5.com? It's very difficult here. 
Don't be offended so easily.

Your posts gave an impression of frustration. (Capital letters are considered shouting)

Some have a more rough way of giving answers, may it be due to pointing out exactly the problem, may it be the way they pose their answeres. Like me, not giving code examples, or missing out on the vibe of the other person.

Happens, we all are different.

But, and that is important, you are working on a machine that will do exactly what you tell it to do. You need to understand every bit you put in. After all, it is about dealing with your money.

There is no room for errors.

Why you need to understand floats.

Because, there are infinite numbers between 0.0 and 1.0.  A computer has only finite amount of storage space. This does not fit into each other, as you can see.

Some engineer at Microsoft figured a way on how to store these values so that a finite storage will give as much numbers as possible. But for the tradeoff, some numbers cannot be stored precisely. So you will need to understand what is going on. Else you will keep having issues with how it works.

MQL is a language that lets you get in fairly easy, but after a short while, a steep learning curve comes in to continue to make progress.

The hints given to you by the people here on the forum are to help you from the start on to have higher expectations and therefore it might sound offending at first.

But be assured, these comments, especially when given every day, multiple times, will be comprehending all relevant details.

Now imagine, I would explain this to each and every person new on mql, I'd be doing this all day. And I'd get into arguments about why, and how.

That's exhausting. So, bringing it down to what it actually is, naming it directly, offends people.

That's why.

You are good here on the forum, don't worry. Just learn how things work here, understand the people, and see for yourself.

Btw, there are some good threads on here to give you plenty of starting points for your journey to mql.