[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 48

 
oDin48:

Guys, please help!

There is a variable counter. I need different actions to be performed on even and odd numbers.

I see it like this

if ((KO/2) > MathFloor(KO/2)) {body1 in which the counter change KO=KO+1;}

if ((KO/2) == MathFloor(KO/2)) {body2 in which the counter change KO=KO+1;}

but body1 is always executed.

The parity is determined by checking the remainder after division:

if (KO % 2 == 0) {} // чётное значение счётчика
else {}             // не чётное
 
Taras, thank you so much!
 
oDin48:

Guys, please help!

There is a variable counter. I need different actions to be performed on even and odd numbers.

I see it like this

if ((KO/2) > MathFloor(KO/2)) {body1 in which the counter change KO=KO+1;}

if ((KO/2) == MathFloor(KO/2)) { body2 in which the counter change KO=KO+1;}

but body1 is executed all the time.

if (MathAbs(MathMod(KO,2) == 0)) {body1 in which the KO counter change is even}

else {body1 in which the KO counter change is odd}

if KO always >=0, then MathAbs() is not required

 
Good afternoon everyone!

Please advise how to align code in MQL4 under Windows 7.

Or how can someone level it?
Thank you.
 
rabanik:
Good day to all!

Could you please advise how to do the MQL4 code alignment in Windows 7?

Or who has already mastered it?
Thank you.

there is no built-in "beautyfinder" in the meta-editor, unlike other more advanced IDEs, and probably won't be

you can "align" (or do it periodically as needed) in any development environment you like (MQ4 is just a standard tessct)

Some people don't use meta-editor at all, and attach the MQL to EX4 compilation script to Notepad+, Hexedit or something else (MQL-coloring scripts for them are available, too)

 
smshev:

A textbook on numerical methods for solving mathematical problems will help you))

e.g. http://www. uchites.ru/files/nummethod_book_chapter3-45.pdf (chapter 3.5. Numerical integration of functions)

although... maybe someone has already done this for themselves

Thanks, if no one else responds, I'll have to remember my youth))))
 
OlegTs:
Thanks, if no one else responds, I will have to remember my youth))))
If accuracy is not too important, you can simply use the rectangular method, i.e. just sum up the original series and get an approximate value of the integral.
 
alsu:
If accuracy is not very important, you can simply use the rectangular method, i.e. by bluntly summing up the original series, you will get an approximate value of the integral.
If it's not too much of a problem, you can just use the rectangular method, i.e.
 
OlegTs:
but more details, if you don't mind, on some five, six bars...
If there is a series x(k), then the integral of x(k) from a to b is approximately x(a) + x(a+1) + .... + x(b-1) + x(b). It is called the rectangular formula.
 
OlegTs:
and more details, if you don't mind, on some five, six bars...
that's exactly the simplest method, which, among other things, is described in the source I cited ))
Reason: