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

 
Alexey Viktorov #:

I wrote about this a few pages ago

I doubt that the examples written into the documentation and even the standard library are thoroughly checked. There are a lot of such errors. Examples, in my opinion, may be used only as samples...

Hello Alexey!

It's very sad that such a serious company has such a poor attitude towards handbooks.

Sincerely, Vladimir.

 
MrBrooklin #:

Hello Alexey!

It's very sad that such a serious company has such a non-serious attitude to the handbook.

Sincerely, Vladimir.

There is another mistake in this example. Or completely blind.

Among the listed mandatory fields there is an expiration, but in the code of the example I don't see where the expiration is assigned. Instead, the allowable deviation from price is assigned.

 
Alexey Viktorov #:

There is still a mistake in this example. Or have I gone completely blind...

Among the listed mandatory fields there is expiration, but in the example code I don't see where expiration is assigned. Instead, the allowable deviation from the price is specified.

Not only expiration time, but it should be there too:

type_time - тип истечения

Sincerely, Vladimir.

 
MrBrooklin #:

Not only that, but there should also be an expiration time:

Sincerely, Vladimir.

I'm addressing Artem Trishkin, the moderator and organizer of this branch!

For your part, do you have the possibility to pass all the questions related to the MQL5 Guide to MQL?

If it's not too much trouble, can you update this page at least ?

Sincerely, Vladimir.
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Типы торговых операций
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Типы торговых операций
  • www.mql5.com
Типы торговых операций - Торговые константы - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
MrBrooklin #:

I'm addressing Artem Trishkin, the moderator and organizer of this thread!

Do you, for your part, have the possibility to pass on to MQL5 all the questions related to the MQL5 Guide?

If you don't mind, at least this page can be updated ?

Respectfully, Vladimir.

You can also report it in this thread.

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2022.02.24
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
 
Alexey Viktorov #:

You can report it in this thread too.

Thanks for the tip, Alexey! I will wait for answer in this thread first, but if nothing happens, I will report it in the Errors, Bugs, Questions topic.

Sincerely, Vladimir.

 
MrBrooklin #:

Thanks for the tip, Alexey! First I will wait for an answer in this thread, but if nothing happens, then I will turn to the Errors, Bugs, Questions thread.

Sincerely, Vladimir.

You won't get any answers from developers in this thread. If you found an error, made sure it was really an error, report it to the branch voiced by Alexey. No need to expect action of moderators on this - we are humans too, and we too sometimes do not have time.

 
Artyom Trishkin #:

You are unlikely to get any answers from the developers in this thread. If you find an error, make sure it is really an error, report it to Alexey's branch. There is no need to expect actions of moderators on this occasion - we are people too, and we too have no time.

Hi Artem!

Everything is clear.

Sincerely, Vladimir.

 

Good afternoon!!!!

Here are two functions for the grid advisor first function is profit calculation, taking into account partial closing of losing orders

//+----------------------------------------------------------------------------+
//| Калькуляция сетки ордеров                                                  |
//+----------------------------------------------------------------------------+
bool CalculiteProfit()
  {
   double oProfit=0,oLoss=0,percent;
   int i;
   nOrd=0;
   for(i = OrdersTotal()-1; i>=0; i--)
     {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES) || OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()>OP_SELL)
         continue;
      if(OrderProfit()>=0)
         oProfit += OrderProfit();
      else
        {
         oLoss+=OrderProfit();
         Ord_ticket[nOrd]=OrderTicket();
         Ord_lot[nOrd]=OrderLots();
         nOrd++;
        }
     }
   oLoss = MathAbs(oLoss+GetOrderSwap()+GetOrderCommission());
   if(oLoss>0)
      percent=oProfit/oLoss*100;
   else
      percent=100;
   if(percent<MinPercentForClose) //MinPercentForClose переменная из настроек 
      return(false);
   for(i=0; i<nOrd; i++)
     {
      Ord_lot[i]=(MathCeil((Ord_lot[i]*RowLots)*percent)/100)/RowLots;
     }
   return(true);
  }

The second function is closing orders with partial closing of unprofitable orders

//+----------------------------------------------------------------------------+
//| Закрытие сетки ордеров при заданной команде с учетом части ордеров         |
//+----------------------------------------------------------------------------+
void ClosseAll()
  {
   int i,j,tkt;

   for(i = OrdersTotal()-1; i>=0; i--)
     {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES) || OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic)
         continue;
      tkt=OrderTicket();
      RefreshRates();
      if(OrderProfit()>=0)
        {
         if(OrderType() == OP_BUY)
           {
            if(!OrderClose(OrderTicket(), OrderLots(), Bid, slip))
               Print("Не удалось закрыть ордера на покупку!");
           }
         else
            if(OrderType() == OP_SELL)
              {
               if(!OrderClose(OrderTicket(), OrderLots(), Ask, slip))
                  Print("Не удалось закрыть ордер на продажу!");
              }
        }
      else
         for(j=0; j<nOrd; j++)
            if(tkt==Ord_ticket[j])
              {
               if(OrderLots()<Ord_lot[j])
                  Ord_lot[j]=OrderLots();
               Ord_lot[j]=NRL(Ord_lot[j]);
               if(OrderType() == OP_BUY)
                 {
                  if(!OrderClose(OrderTicket(), Ord_lot[j], Bid, slip))
                     Print("Не удалось закрыть ордера на покупку!");
                 }
               else
                  if(OrderType() == OP_SELL)
                    {
                     if(!OrderClose(OrderTicket(), Ord_lot[j], Ask, slip))
                        Print("Не удалось закрыть ордер на продажу!");
                    }
               break;
              }
     }
  }

The situation is as follows: if I close a grid of orders while taking into account partial closing of losing orders, I get a loss as a result of rounding to the bigger side of some lots which need to be closed

The question is whether you can use these two functions to write a function for calculating losing orders, or rather a part of an order to be closed.

If so, please help me write it

Thank you

 
EVGENII SHELIPOV #:

Good afternoon!!!!

If so, help me write it.

It's not a good time.

You mean write it for you?