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

 
MakarFX #:

Not critical, but there is an explanation for everything...

YOU have that explanation

 
MakarFX #:

Not critical, but there is an explanation...

Or assumptions

 
EVGENII SHELIPOV #:

Or assumptions

Need the whole code to look at in the tester.
 
MakarFX #:
Need the whole code to look at in the tester.

Please see

Files:
111.mq4  48 kb
 
EVGENII SHELIPOV #:

BAC has this explanation

Before modifying an order, you should check if the values being set are the same as those already in the order.
And if all the values are the same, there is no need to make the modification.

 
Taras Slobodyanik #:

Before modifying an order, you should check if the values set are the same as those already in the order.
And if all the values are the same, there is no need to make the modification.


//+----------------------------------------------------------------------------+
//| Модификация групповых ордеров                                              |
//+----------------------------------------------------------------------------+
void ModifyOrders(int otype)
{
    double avg_price, order_lots = 0;
    price = 0;


    for(int i = OrdersTotal()-1; i>=0; i--)
    {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
         {
            price += OrderOpenPrice() * OrderLots();
            order_lots += OrderLots() ;
         }
       }
    }
    avg_price = NormalizeDouble(price / order_lots, Digits);
     {
     ObjectDelete(0, "AveragePriceLine");
     ObjectCreate(0,"AveragePriceLine" ,OBJ_HLINE, 0, 0, avg_price);
     ObjectSet("AveragePriceLine",OBJPROP_COLOR, Magenta);
     }
    if (otype == OP_BUY) tp = NormalizeDouble (avg_price + TakeProfitGroupOrder*Point, Digits);
    if (otype == OP_SELL) tp = NormalizeDouble (avg_price - TakeProfitGroupOrder*Point, Digits);
    if ((otype == OP_BUY || otype == OP_SELL) && (Drawdown > DrawdownClosingTakeprofitZero)) 
    tp = NormalizeDouble (avg_price, Digits);
    for(int i = OrdersTotal()-1; i>=0; i--) 
    {
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
           if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
           {
               if(OrderModify(OrderTicket(), OrderOpenPrice(), 0, tp, 0))
                  Print("Ордера успешно модифицированы!");
                else Print("Ошибка модификации ордеров!");
           }
       }
    }
}

Is this the check you are talking about?

 
EVGENII SHELIPOV #:

Is this the check you are talking about?

You need to check if the value already set in the order matches the one to be set.

  • tp==OrderTakeProfit()
  • Also, if sl==OrderStopLoss() is required
  • also if needed price==OrderOpenPrice()

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype && tp!=OrderTakeProfit() )
 
Taras Slobodyanik #:

The value already set in the order should be checked to see if it coincides with the one to be set.

  • tp==OrderTakeProfit()
  • Also, if sl==OrderStopLoss() is required
  • also if needed price==OrderOpenPrice()

Taras, could you explain what I need it for if I modify a grid of orders with decreased min and max orders and respectively need to calculate a new average price and modify the new take profit

 
EVGENII SHELIPOV #:

Taras, can you explain why I need this if I modify a grid of orders in which the min and max orders are reduced, respectively I need to calculate a new average price and modify the new take profit

er, didn't you ask about the modification error and its criticality?
...and its explanation

 
MakarFX #:
It's not there.