Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 540

 
Rustam Bikbulatov:

Thanks!!!!! Now I'll try to squeeze it into my code! Why on the first line (void) ?

And why do you need to specify order type if the function name says that it considers Buy orders?
 
Artyom Trishkin:
And why do you need to specify the order type if the function name says that it considers Buy orders?

The name can be changed in seconds, but the code itself is a problem

 
Rustam Bikbulatov:

You can change the name in seconds, but there's a problem with the code itself

The problem is not with the code, but with your understanding of what you're doing :)

//+------------------------------------------------------------------+
int fMarketOrdersOpen(const ENUM_ORDER_TYPE order_type)
  {
   int total=OrdersTotal(), count=0;
   for(int i=total-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS))
        {
         if(OrderType()!=order_type) continue;
         if(OrderMagicNumber()==123 && OrderSymbol()==Symbol())
            count++;
        }
     }
   return count;
  }
//+------------------------------------------------------------------+
 
Rustam Bikbulatov:
Guys. My brain is already bubbling((( Please, advise how to use this definition of the orders quantity

make the amount of volume in lots? What needs to be changed or tweaked?

double fMarketOrdersOpenB(int type){
   double c=0,aBuyCount=0;
   for(int i=0;i<OrdersTotal();i++){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==123){
            switch(OrderType()){
               case OP_BUY:aBuyCount+=OrderLots();break;
              }}}else{return(-1);}}
   if(type==OP_BUY)c=aBuyCount;return(c);}

If you fail to select at least one order, this function will return -1.

If the type corresponds to OP_BUY - you will get the BUY lots volume

If the value of type is different, the function will return 0.

If I have understood the task correctly - change the count of units to the count of BUY order lots
 
Kirill Belousov:

If at least one order is not selected correctly, the function will return -1

If the type corresponds to OP_BUY - you will get the BUY lots volume

If the value of type is different, this function will return 0.

If I have understood the task correctly, it is to change the piece count to the BUY order lot count

Yes, exactly. I can't figure it out

 
Artyom Trishkin:

The problem is not with the code, but with your understanding of what you do :)

i agree that i don't understand programming completely. well, it's not my thing((((

 
Initially this code
int fMarketOrdersOpenB(int type){
   int c=0,aBuyCount=0;
   for(int i=0;i<OrdersTotal();i++){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==123){
            switch(OrderType()){
               case OP_BUY:aBuyCount++;break;
              }}}else{return(-1);}}
   if(type==OP_BUY)c=aBuyCount;return(c);}

I need to insert

     .........
double lts=fMarketOrdersOpenB(OP_BUY);
   if(lts>0){
         int irv2=OrderSend(Symbol(),OP_BUY,lts,Ask,3,0,0,NULL,123,0,CLR_NONE);}

My code prints the number of orders but I need the lot volume of all buy orders

 
Rustam Bikbulatov:
This code is originally

I need to insert

My code prints the number of orders and I need the lot volume of all buy orders

The most important thing is to ask the right question.

Find out for yourself what you need

Только "Полезные функции от KimIV".
Только "Полезные функции от KimIV".
  • 2011.02.18
  • www.mql5.com
Все функции взяты из этой ветки - http://forum.mql4...
 
Vitaly Muzichenko:

The most important thing is to ask the right question.

Look for yourself what you need

Seen and tried. Helped a lot already but there is a limit to my understanding

 
Rustam Bikbulatov:
Guys. Already my brain is boiling((( Can you tell me how to make the number of orders out of this definition?

make the amount of volume in lots? What needs to be changed or tweaked?

double fMarketOrdersOpenB(const ENUM_ORDER_TYPE type)
{
     double lots=0;
     for(int i=0;i<OrdersTotal();i++)
     {
          if( !OrderSelect(i,SELECT_BY_POS,MODE_TRADES) )   continue;
          if( OrderSymbol()!=Symbol() )                     continue;
          if( OrderMagicNumber()!=123 )                     continue;
          if( OrderType() != type )                         continue;
          lots += OrderLots();
     }
     return(lots);
}
Reason: