Someone should update the MQL4 Book

234

As a matter of interest to Newbies (myself included)

There is a blatant  error in the MQL4 Book... where it comes to Loops...

It's taken me almost 2 years to become semi-proficient in MQL coding... But, one thing that I have learnt in this game is that you have to Decrement the loop... This is very important in my opinion and Raptor explains this perfectly..

https://forum.mql4.com/48352

I decided to re-read the MQL4 Manual (and everything has just become clear as daylight).... from taking a bit of code here...and a bit there.... I think I can now hold my ground in this forum....

BUT... someone should change Sergey's approach... it taught me bad things and I'm sure it is still teaching new programmers bad things...

With respect...

MikeT

234

Mike.T:

As a matter of interest to Newbies (myself included)

There is a blatant  error in the MQL4 Book... where it comes to Loops...

It's taken me almost 2 years to become semi-proficient in MQL coding... But, one thing that I have learnt in this game is that you have to Decrement the loop... This is very important in my opinion and Raptor explains this perfectly..

https://forum.mql4.com/48352

I decided to re-read the MQL4 Manual (and everything has just become clear as daylight).... from taking a bit of code here...and a bit there.... I think I can now hold my ground in this forum....

BUT... someone should change Sergey's approach... it taught me bad things and I'm sure it is still teaching new programmers bad things...

With respect...

MikeT

Sorry... I should have explained myself better...

for(PositionIndex = 0; PositionIndex < TotalNumberOfOrders; PositionIndex++)  //  <-- for loop to loop through all Orders

Should be....

for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)  //  <-- for loop to loop through all Orders . .   COUNT DOWN TO ZERO !

234

Mike.T:

Sorry... I should have explained myself better...

The first instance increments the loop...

...the second "Decrements" the loop.... and that is what you want if you need accurate information to pass on...

Anyways...

Plz correct me if I am wrong...