I need to determine whether a given number is even or odd.
How do I do this?
An option is to divide by 2 and check the remainder using mathematical functions, for example,
doubleMathMod( double value, double value2)
Функция возвращает вещественный остаток от деления двух чисел.
Функция MathMod рассчитывает вещественный остаток f от x / y таким образом, что x = i * y + f , где i является целым числом, f имеет тот же знак, что и x, и абсолютное значение f меньше, чем абсолютное значение y.
Параметры:
value - Значение делимого.
value2 - Значение делителя.
Пример:
double x=-10.0,y=3.0,z;
z=MathMod(x,y);
Print("Остаток от ",x," / ",y," есть ",z);
// Вывод: Остаток от -10 / 3 есть -1
If the remainder != 0, then odd, if = 0, then even.
Good afternoon! Question in forum organisation, I have done a bit of research. I would like to post it on the forum, to hear some criticism from experts. How can I do this, start a separate topic?
orb: Good afternoon! Question in forum organisation, I have done a bit of research. I'd like to post it on the forum, hear some criticism from the experts. How to do it, have a separate topic?
Can you advise if I create a synthetic chart of a non-standard timeframe (for example M2 using period_converter script), how can I request indicator value from this chart when testing the EA? Is it ok?
In any indicator insert the Symbol() and Period() and put the indicator on a non-standard TF. The obtained data will dispel all doubts and you can safely insert it in the bush.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I can't find such a function.
I need to determine whether a given number is even or odd.
How do I do this?
I can't find such a function.
I need to determine whether a given number is even or odd.
How do I do this?
If the remainder != 0, then odd, if = 0, then even.An option is to divide by 2 and check the remainder using mathematical functions, for example,
Good afternoon! Question in forum organisation, I have done a bit of research. I'd like to post it on the forum, hear some criticism from the experts. How to do it, have a separate topic?
It would be better to have a separate topic
A separate topic would be better!
if(var%2!=0){ same thing, only simpler;}
Even simpler:
Can you advise if I create a synthetic chart of a non-standard timeframe (for example M2 using period_converter script), how can I request indicator value from this chart when testing the EA? Is it ok?