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

 
EVGENII SHELIPOV #:

Makar, can you explain from which place of the code the function will be referred to?

If there are more than 1 order

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
   {
//---
   if(CountTrade()>1) TrailingGroupOrder();
   }
 
MakarFX #:

Sorry, I wrote for 4...

Checked in 5! It's working.

Thanks. Very strange that my version didn't work. I broke my brain)))

 
Andrey Sokolov #:

Thank you. It's very strange that my option didn't work.

It's not weird...

you didn't write the paths, here's your code

   string src_path; 
   string dst_path; 
   StringConcatenate(src_path,"","//",name_file); 
   StringConcatenate(dst_path,name_folder,"//",name_file); 
   ResetLastError();
   if(FileMove(src_path,0,dst_path,0)){

and what does "src_path" and "dst_path" equal?

 
MakarFX #:

If there are more than 1 order

No Makar, it doesn't work

 
MakarFX #:

It's not strange...

you didn't write the paths, here's your code

and what do "src_path" and "dst_path" equal?

they are written in the next two lines, took it from the helphttps://www.mql5.com/ru/docs/files/filemove

This is not the point, this code worked in mt4, and I moved the first screenshot in mt5.

 
EVGENII SHELIPOV #:

No Makar, it doesn't work

It can't be... Give me all the code in the private message.
 
MakarFX #:
No way... Give me the whole code in your inbox.

I have sent you

 
EVGENII SHELIPOV #:

I have sent you

Reply
 
MakarFX #:
replied

Makar thank you I will keep thinking

 
MakarFX #:
replied

Good day Makar !!!

Following your advice, I have found a place in void OnTick() function where I can attach the TrailingGroupOrder() function to send a command to modify a trail of group orders, and oh my god the trail of group orders has started working. However, my joy didn't last long. Looking closer, I saw that only the order with a min ticket is trilled.

//+----------------------------------------------------------------------------+
//| Трейлинг стоп групповых ордеров                                            |
//+----------------------------------------------------------------------------+
void TrailingGroupOrder()
{
    for(int i = OrdersTotal()-1; i>=0; i--)
    {
     if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
       if(OrderType() == OP_BUY && Bid - GetAveragePrice() > TrailingStopGroupOrder*Point)
        {
        if(Bid - GetAveragePrice() > TrailingStopGroupOrder*Point || OrderStopLoss() == 0)
         {
         if(OrderStopLoss() < Bid - (TrailingStep + TrailingStopGroupOrder )*Point || OrderStopLoss() == 0)
          {
          if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - TrailingStopGroupOrder*Point, Digits), tp, 0))
                    Print("Ошибка модификации групповых ордеров на покупку!");
          }
         }
        }
        if(OrderType() == OP_SELL && GetAveragePrice() - Ask > TrailingStopGroupOrder*Point)
         {
         if(GetAveragePrice() - Ask > TrailingStopGroupOrder*Point || OrderStopLoss() == 0)
           {
            if(OrderStopLoss() > Ask + (TrailingStep + TrailingStopGroupOrder)*Point || OrderStopLoss() == 0)
              {
              if(!OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + TrailingStopGroupOrder*Point, Digits), tp, 0))
                    Print("Ошибка модификации групповых ордеров на продажу!");
              }
           }
         }
      } 
    }
}

I can very likely assume that the problem is in the modification of only the first (minimum) order and not all at once.

Makar advise how to modify all orders in the grid????