counting open orders

Back to topics list To post a new topic, please log in or register
avatar
56
Dannoo007 2015.10.06 21:14
 
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.


 




avatar
Moderator
3423
GumRai 2015.10.06 22:01 #
 
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 

avatar
13008
WHRoeder 2015.10.07 14:24 #
 
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?

Back to topics list  

To add comments, please log in or register