Function that returns ONLY market orders count. Please

 
BIGBLACKFEET:

Hi,

Is there a function returning ONLY the market orders count, Please

TIA

Best regards

BBF

OrdersTotal( )

 
ggekko wrote >>

OrdersTotal( )

Thanks for trying to help... but this function return market orders count AND pending orders count.

I'm interested for a function that returns the market orders count ONLY.

Best regards

BBF

 

Hi,

No there is no such function. You have to make a loop counting the orders you want to count, according to the TYPE to select wether it is a pending order or not.

I give you an idea of what I mean:

int MarketOrderCount()
  {int answer = 0;
   int curOrder, numOrders = OrdersTotal();
   for(curOrder = 0; curOrder < numOrders; curOrder++) 
      {// GET ORDER
       if (!GetOrderByPos(curOrder))                    
          return(9999);
       // GET ORDER OK
       if (OrderType() != OP_BUY  &&  OrderType() != OP_SELL)  // no pending orders will be treated  
                                                               //(or test with other OP_ options depending on your 
                                                               //treatments)          
          continue;   // jump to the next element in the loop
       answer++;
      }
   return(answer) 
  }        

Check this out, I just wrote it like that not even compiled it.
 
BIGBLACKFEET:

Thanks for trying to help... but this function return market orders count AND pending orders count.

I'm interested for a function that returns the market orders count ONLY.

Best regards

BBF

Ok, here you are:

  int c = 0;
  int total  = OrdersTotal();

  for (int cnt = 0 ; cnt < total ; cnt++)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if (OrderType()==OP_BUY || OrderType()==OP_SELL)
    {
      c++;
    }
  }
  

Cheers
 

BBF

Something like this...

int OpenTradesForMNForType(int iMN, int iType)
{
 // Call as example 
 // if(OpenTradesForMNForType(MagicNumber, OP_BUY) < 2)....

int icnt, itotal, retval;

retval=0;
itotal=OrdersTotal();

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

     }

return(retval);
}

Good Luck

-BB-

 
BarrowBoy wrote >>

BBF

Something like this...

Good Luck

-BB-

Hi,

ggekko, jacques366, and you BarrowBoy, all of you, you have been quite nice... and efficient.

Great indeed

Thanks again

Best regards

BBF

Reason: