[ Ссылка ]
In this video we will look at some basic mathematical functions for rounding values in MQL four and create an Expert Advisor that performs various mathematical operations and displays the results directly on your Forex chart.
Before we begin, let's talk briefly about why it's so valuable to create small sample programs. When you first start programming, or specifically with MQL four, it can sometimes be overwhelming to understand all of the features and capabilities. By writing small sample programs, you can isolate and test specific functions. This not only provides a better understanding, but also helps identify sources of errors in larger programs.
First, we define two variables. named here. The first variable has a value of one point seven seven seven and the other has a value of one point three three.
We use the MathRound function to round the values we created to the nearest integer. This function returns the rounded value of the number passed in.
The MathFloor function returns the largest integer value that is less than or equal to the number passed in. In our case, we use it to get the largest integer value that is less than or equal to the variable values.
The MathCeil function returns the smallest integer value that is greater than or equal to the number passed in. We use it to get the smallest integer value that is greater than or equal to the variable values.
Finally, we use the Comment function to display the calculated values directly on the chart. This function allows text information to be output on the chart.
To see how this code looks in action, please click on the small icon here or press F seven on your keyboard to compile the program code. After you have compiled the code, you can return to Metatrader and launch the Strategy Tester.
We hope that this video has given you a clear insight into how to use some basic mathematical functions in MQL four. With just a few lines of MQL four code, you will have created an Expert Advisor that displays valuable information directly on your chart.
If this was all too fast for you or you don't understand exactly what all the code does, you may want to take the premium course on our website or watch one of our fundamentals videos first.
If you are already a member of our premium course and have an idea for a video, feel free to email us.
Thanks for watching and I will see you in the next video!
![](https://i.ytimg.com/vi/pmVC8yMBQ0s/mqdefault.jpg)