[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 526

 
please help! https://forum.mql4.com/ru/45849
 

I can't find such a function.

I need to determine whether a given number is even or odd.

How do I do this?

 
Alp:

I can't find such a function.

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,

double MathMod( 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.
 
Thanks for looking something up.
 
if(var%2!=0){ same thing, only simpler;}
 
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?

It would be better to have a separate topic
 
Vinin:

A separate topic would be better!
Thank you!
 
FAQ:
if(var%2!=0){ same thing, only simpler;}


Even simpler:

if(var%2)
{//число нечетное } 
else
{//число четное } 

 
Neelan:

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.