Very noob question - will delete soon

 
Why do MQL5TUTORIALS from youtube uses 

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

What's the purpose of adding -1, why couldn't it just be 

for (int i = PositionsTotal(); i>=0 ; i--)
 

Try to learn the concept of an array.

PositionTotals() is the size of an array, for loop of "i" is an index and index start with 0 instead of 1.

for example, an array of [a, b, c, d, e, f] has total size of 6 (PositionsTotal() = 6). So if you want to count backward in that array, you start with index of 5 (6 minus 1).

because [ a (index is 0), b (index is 1), c (index is 2), d (index is 3), e (index is 4), f (index is 5)]

 
Ahmad Zuhairdi Noh:

Try to learn the concept of an array.

PositionTotals() is the size of an array, for loop of "i" is an index and index start with 0 instead of 1.

for example, an array of [a, b, c, d, e, f] has total size of 6 (PositionsTotal() = 6). So if you want to count backward in that array, you start with index of 5 (6 minus 1).

because [ a (index is 0), b (index is 1), c (index is 2), d (index is 3), e (index is 4), f (index is 5)]

I was sure i'm missing out an important concept, thank you!

 
Ahmad Zuhairdi Noh:

Try to learn the concept of an array.

PositionTotals() is the size of an array, for loop of "i" is an index and index start with 0 instead of 1.

for example, an array of [a, b, c, d, e, f] has total size of 6 (PositionsTotal() = 6). So if you want to count backward in that array, you start with index of 5 (6 minus 1).

because [ a (index is 0), b (index is 1), c (index is 2), d (index is 3), e (index is 4), f (index is 5)]

Wait, by using the same logic why does PositionsTotal()==0 means no open positions, in an array of [a,b,c,d,e,f] it should be selecting [a] which means there is 1 open position

 
PositionsTotal()==0 does mean no open positions. If there are n positions (count), their indexes are [0 … n-1]