Need help to understand this coding

 
hi guys! i need help from you guys to guide me, what is this mean : for (order = 0; order < OrdersTotal()-1 ; order++) what I don't understand is, what is the purpose of OrdersTotal()-1? why orderstotal minus 1? your help is much appreciated. thanks in advance!
 
Order information ar stocated into array.The first line in line 0.If have 3 orders on line 0 find info about first order.
 

Here's a tip.

Don't use this code.

I wish someone would take the person who wrote it, cut off their hands and confiscate their keyboard.

Instead use a loop which counts downwards rather than upwards.

The reason is that each time you delete an order, the remaining orders are reindexed - so if you are counting upwards, your loop is going to miss some orders.


CB

 

OrdersTotal() returns the number of open and pending trades.

If it returns the value 3, you have three positions open or pending.

They are stored in index 0, 1, and 2 of the orders pool.

So...

for (int i = OrdersTotal()-1; i >= 0; i--)

... will loop "backwards" through the pool of orders, starting with index #2.

Same thing with OrdersHistoryTotal()., but it is the number of Closed orders.

 
Thanks guys!
Reason: