Function to get Total Orders for one Symbol?

To add comments, please log in or register
pob
13
pob  
Hi all,

is there a function to get Total Open Orders for one Symbol only?
As far as I know TotalsOrder() will return all Open Orders for all symbols.

Thanks in advance
pob
mike_s
152
mike_s  
As far as I know, there is no such function in the reference.

But you can easily build one yourself.
Make a loop on the orders pool, and if the current order symbol matches the chart symbol -> counter++.
Brian Dee - Random Trader
1758
Brian Dee - Random Trader  
Pob
You will usually need a count by MagicNumber & OrderType as well as Symbol
So something like
int OpenTradesForMNandPairType(int iMN, string sOrderSymbol, int iType)
{
int icnt, itotal, retval;

retval=0;
itotal=OrdersTotal();

   for(icnt=0;icnt<itotal;icnt++) // for loop
     {
      OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES);
       // check for opened position, symbol & MagicNumber
       if (OrderSymbol()== sOrderSymbol)
        {
          if (OrderMagicNumber()==iMN) 
            {
              if(OrderType()==iType) retval++;
            }       
        } // sOrderSymbol
     } // for loop

return(retval);
}

FWIW
-BB-
pob
13
pob  
Thanks a lot guys!

:)

Mehmet Bastem
1672
Mehmet Bastem  
pob:
Hi all,

is there a function to get Total Open Orders for one Symbol only?
As far as I know TotalsOrder() will return all Open Orders for all symbols.

Thanks in advance
pob

mt4 standars indicatore iExposure.mq4

https://www.mql5.com/en/charts/9147694/usdcad-m5-alnus-yatirim-menkul

Chart USDCAD, M5, 2018.09.20 11:03 UTC, Alnus Yatirim Menkul Degerler A.S., MetaTrader 4, Demo
Chart USDCAD, M5, 2018.09.20 11:03 UTC, Alnus Yatirim Menkul Degerler A.S., MetaTrader 4, Demo
  • www.mql5.com
Symbol: USDCAD. Periodicity: M5. Broker: Alnus Yatirim Menkul Degerler A.S.. Trading Platform: MetaTrader 4. Trading Mode: Demo. Date: 2018.09.20 11:03 UTC.
To add comments, please log in or register