OP_ALL is not working

 

Hello,

Code to count orders :

int trade_count_ordertype(int trade_count_ordertype_value, int trade_count_ordertype_magic)
  {
   int count_4 = 0;
   for(int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++)
     {
      OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol() != Symbol() || OrderMagicNumber() != trade_count_ordertype_magic)
         continue;
      if(trade_count_ordertype_value == OrderType())
         count_4++;
     }
   return count_4;
  }

OP_ALL is not working

LastOrderPrice(OP_BUY, 5555);  // => Working
LastOrderPrice(OP_SELL, 5555);  // => Working
LastOrderPrice(OP_BUYLIMIT, 5555);  // => Working
LastOrderPrice(OP_SELLLIMIT, 5555);  // => Working
LastOrderPrice(OP_BUYSTOP, 5555);  // => Working
LastOrderPrice(OP_SELLSTOP, 5555);  // => Working
LastOrderPrice(OP_ALL, 5555); // => Not working

OP_ALL = All the orders (BUY + SELL + BUYLIMIT + SELLLIMIT + BUYSTOP + SELLSTOP)

 
anuj71:

Hello,

Code to count orders :

OP_ALL is not working

OP_ALL = All the orders (BUY + SELL + BUYLIMIT + SELLLIMIT + BUYSTOP + SELLSTOP)

OP_ALL constant does not exist. Where did you get that?

 
Laszlo Tormasi #:

OP_ALL constant does not exist. Where did you get that?

Than, if i want total number of orders, how can i get it without writing another standalone function for that?


And in another EA code, i saw OP_ALL



 
anuj71 #:

Than, if i want total number of orders, how can i get it without writing another standalone function for that?


And in another EA code, i saw OP_ALL


no such thing as OP_ALL  must be developer defined if you have seen it elsewhere

 
Paul Anscombe #:

no such thing as OP_ALL  must be developer defined if you have seen it elsewhere

Than how can i achieve the result i want without making new function code?. If i want total number of orders, How i can do this?.

I can do this by writing new function code like this :

int trades_count(int trade_count_magic)
  {
   int count_0 = 0;
   for(int pos_4 = 0; pos_4 < OrdersTotal(); pos_4++)
     {
      OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol() != Symbol() || OrderMagicNumber() != trade_count_magic)
         continue;
      count_0++;
     }
   return count_0;
  }

trades_count(5555);


But this will be function overloading. and it excess of code and decrease EA performance. How i can achieve the result without adding new function?

 
anuj71 #:

Than how can i achieve the result i want without making new function code?. If i want total number of orders, How i can do this?.

I can do this by writing new function code like this :


But this will be function overloading. and it excess of code and decrease EA performance. How i can achieve the result without adding new function?

why don't you use the documentation for once,  you can get total orders, but if you want a subset of that total you will have to write a function to do it.

https://docs.mql4.com/trading

Trade Functions - MQL4 Reference
Trade Functions - MQL4 Reference
  • docs.mql4.com
Trade Functions - MQL4 Reference
 
anuj71 #:

Than how can i achieve the result i want without making new function code?. If i want total number of orders, How i can do this?.

I can do this by writing new function code like this :


But this will be function overloading. and it excess of code and decrease EA performance. How i can achieve the result without adding new function?

#define OP_ALL -1
int trade_count_ordertype(int trade_count_ordertype_value, int trade_count_ordertype_magic)
  {
   int count_4 = 0;
   for(int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++)
     {
      OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol() != Symbol() || OrderMagicNumber() != trade_count_ordertype_magic)
         continue;
      if(trade_count_ordertype==OP_ALL || trade_count_ordertype_value == OrderType())
         count_4++;
     }
   return count_4;
  }
 
Laszlo Tormasi #:

Question is adding #define OP_ALL -1 will help me what i want?. Does -1 means All order type?

 

Hi

Perhaps it was defined somewhere else in this code you have seen.

Those are simply converted to numbers while using as “indexes” for arrays - so when you define this as OP_ALL=10, and then fill the array for this index properly you can use this as a global counter for all trades.

Best Regards

 
anuj71 #:

Question is adding #define OP_ALL -1 will help me what i want?. Does -1 means All order type?

Forget OP_ALL it doesn’t exist
Just write your own function to do what you want
Loads of examples if you search instead of asking every time
 
anuj71 #:

Question is adding #define OP_ALL -1 will help me what i want?. Does -1 means All order type?

There is another change in the code. Have you seen that? 

      if(trade_count_ordertype==OP_ALL || trade_count_ordertype_value == OrderType())
         count_4++;