Simple Question on OrderTotal()

Back to topics list To post a new topic, please log in or register
avatar
3
airified 2015.07.14 02:12
 

Hey all, googled for OrderTotal() doc but seems to be missing something.

 Have noticed that for looping through open/pending orders, people use for(i=0, i < OrderTotal(), i++) Or for(i=OrderTotal() - 1, i>=0, i--).

 

Dumb qns but can I check why is it  i=OrderTotal() - 1 and not i=OrderTotal() if I want to check if i have any open orders of a particular currency before opening a new trade? (to prevent holding 2 positions of the same currency)

avatar
Moderator
3404
GumRai 2015.07.14 03:38 #
 

Because indexing starts at 0, whereas counting starts at 1

So if there are 2 open orders, the first one will be indexed 0 and the 2nd will be indexed 1

So the highest index number will always be 1 less than the total 

avatar
3
airified 2015.07.14 03:55 #
 
GumRai:

Because indexing starts at 0, whereas counting starts at 1

So if there are 2 open orders, the first one will be indexed 0 and the 2nd will be indexed 1

So the highest index number will always be 1 less than the total 

Hey GumRai thanks for the explanation!!
Back to topics list  

To add comments, please log in or register