Download MetaTrader 5
To add comments, please log in or register
Register as a seller and start making profit!
zerosen
31
zerosen 2015.07.30 03:51 

Hi,

 Im a student who have just started trying MQL4. Im having issue finding the function to count the number of open position. Also, confused with the jargon so there may be some error in the words.

 

Lets say the price is 80 and i put an pending order to buystop at 90. To count the number of pending order, i use OrdersTotal() . correct?

if the price hits 90 and the buystop get triggered, but not the stoploss or takeprofit, it is a open position right? is there a function to count this? Do not count if the stoploss/takeprofit is triggered (close position).

 

OrdersHistoryTotal() would count both the open and close position right? Is there a way to count only the open position? or a way to count all the closed position so i can work backwards?

 

Thank you in advance for helping this newbie  

Keith Watford
Moderator
7960
Keith Watford 2015.07.30 04:40  

OrdersTotal()  is the number of open orders including pending orders

OrdersHistoryTotal() is the number of closed orders and may include cancelled pending orders 

if the price hits 90 and the buystop get triggered, but not the stoploss or takeprofit, it is a open position right? is there a function to count this? Do not count if the stoploss/takeprofit is triggered (close position). 

 A current pending order is still an open order even though it has not yet triggered.

If you want to check how many open pending orders there are, loop through the open orders and check OrderType() 

zerosen
31
zerosen 2015.07.30 21:40  
GumRai:

OrdersTotal()  is the number of open orders including pending orders

OrdersHistoryTotal() is the number of closed orders and may include cancelled pending orders 

 A current pending order is still an open order even though it has not yet triggered.

If you want to check how many open pending orders there are, loop through the open orders and check OrderType() 

I was misinterpreting the OrdersTotal() as open orders only. Thanks for the clarification :)

/
To add comments, please log in or register