counting open orders

 
int sellOrdersCount(){
   int SellOrdersCounting = 0;
   for (int iSELL = OrdersTotal()-1; iSELL >=0; iSELL--){
      if( OrderSelect(iSELL, SELECT_BY_POS, MODE_TRADES) && OrderSymbol()== EURUSD && OrderMagicNumber()== 1234 && OrderType() == OP_SELL ){
         SellOrdersCounting++;
      }
   }
   return( SellOrdersCounting );
}


Hello forum,

two quick questions:

1) I am trying to count the number of open orders, using the function above. I placed it in the global scope, just below the ending of OnTick. I am calling on it and looks as thought it returns ZERO...I feel  am missing something, anything wrong with the writing?

2) regarding OrdersTotal() - what happens if I run several separate EA's with their own separate magics on the same account/terminal, what will OrdersTotal() return, say in the case above? All open orders in the terminal regardless of magic or only the ones opened from it's "home EA" and corresponding magic?

Thanks in advance for support!

Dan.

 
Dannoo007:


1) I am trying to count the number of open orders, using the function above. I placed it in the global scope, just below the ending of OnTick. I am calling on it and looks as thought it returns ZERO...I feel  am missing something, anything wrong with the writing?

2) regarding OrdersTotal() - what happens if I run several separate EA's with their own separate magics on the same account/terminal, what will OrdersTotal() return, say in the case above? All open orders in the terminal regardless of magic or only the ones opened from it's "home EA" and corresponding magic?

Are there any sell orders open on EURUSD and with magic number 1234?

OrdersTotal() returns the number of all open orders 

 
if( OrderSelect(iSELL, SELECT_BY_POS, MODE_TRADES) && OrderSymbol()== EURUSD && OrderMagicNumber()== 1234 && OrderType() == OP_SELL ){

What does the variable EURUSD contain? Why don't you just use the current chart _Symbol

Are you opening order's with that magic number?

Reason: