int i,active ; double TopPrice=0, MinPrice=100000 ; //Min price must start as a large number int TopTicket, MinTicket ; active = OrdersTotal() ; for (i=active-1; i>=0; i--) { if ( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ) { if ( OrdType == OrderType() && Symbol()=OrderSymbol() ) //or other checks to filter out orders from other charts { if ( MinPrice > OrderOpenPrice() ) { MinPrice=OrderOpenPrice() ; MinTicket = OrderTicket() ; } if ( MaxPrice < OrderOpenPrice() ) { MaxPrice=OrderOpenPrice() ; MaxTicket = OrderTicket() ; } } //end if ( OrdType == } // end if ( OrderSelect } //end for
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
We know that, in order to access such order details; the order should be selected first by indexing the opened positions.
i.e.
Now, the gathered OrderOpenPrice() at i = k should be stored somehow in order to be compared with its corresponding value for the next iteration (k+1).
For me, I see that; additional auxiliary index say j should be used to carry out that task, but WHAT and HOW?
What is the relation between i and j with respect to OrdersTotal()?
and How can we implement another inner loop (using j index) under the main loop (using i index)?
Any ideas please?