How to Order Count in mql5

 

i am trying few hours to count total open position of magic number 0  for mt5. and want to get open price of all orders?

int GetOrdersTotalByMagic(long const magic_number) 
  { 
   ulong order_ticket; 
   int total=0; 
//--- go through all pending orders 
   for(int i=0;i<OrdersTotal();i++) 
      if((order_ticket=OrderGetTicket(i))>0) 
         if(magic_number==OrderGetInteger(ORDER_MAGIC)) total++; 
//--- 
   return(total); 
  } 


i also tried SymbolSelect, it returns me only first order openprice and lot sizes . but how to retrive all open order lot size and openprice.

i really appreciate if some one help

 
Muhammad Mudasir:

i am trying few hours to count total open position of magic number 0  for mt5. and want to get open price of all orders?


i also tried SymbolSelect, it returns me only first order openprice and lot sizes . but how to retrive all open order lot size and openprice.

i really appreciate if some one help

Use PositionsTotal();

https://www.mql5.com/en/docs/trading/positionstotal

Documentation on MQL5: Trade Functions / PositionsTotal
Documentation on MQL5: Trade Functions / PositionsTotal
  • www.mql5.com
Trade Functions / PositionsTotal - Reference on algorithmic/automated trading language for MetaTrader 5
 
Roberto Jacobs:

Use PositionsTotal();

https://www.mql5.com/en/docs/trading/positionstotal


Got it bro thanks for the help
 
Muhammad Mudasir:

Got it bro thanks for the help

OrdersTotal for Pending Orders
Reason: