Toute question des nouveaux arrivants sur MQL4 et MQL5, aide et discussion sur les algorithmes et les codes. - page 1639

 
MakarFX #:
Alors, que voulez-vous de toute façon ?)

Je l'ai déjà fait. Peut-être un peu négligé. Corrigez-moi. Je calcule d'abord le prix de la dernière, puis celui de l'avant-dernière.
Mais il y a un autre problème. Depuis le contrôle de tous les Comment -ami dans le coin, tout le temps si la valeur de pendaison n'est pas impliquée égale à DBL_MAX. Comment l'enlever, surligné en rouge)

double MinOpenSell() // ищу ордер по самой низкой цене.
{
   double oldticket, UpPrice = DBL_MAX;
   
   for(int cnt=OrdersTotal(); cnt>=0; cnt--)
   {
      if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL)
         {
            oldticket = OrderOpenPrice();
            if ( oldticket < UpPrice)
            {
               UpPrice = oldticket;
            }
         }
      }
   }
   return(UpPrice);
}
double FindPenultSellPrice() // а тут ищу предпоследний)
  {
   double oldticket, UpPrice = DBL_MAX;
   
   for(int cnt=OrdersTotal(); cnt>=0; cnt--)
   {
      if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL)
         {
            oldticket = OrderOpenPrice();
            if ( oldticket < UpPrice && MinOpenSell()< oldticket)
            {
               UpPrice = oldticket;
            }
         }
      }
   }
   return(UpPrice);
}
 
makssub #:

Comme le contrôle est tout Comment -ami dans le coin, tout le temps si non engagé la valeur pend égale à DBL_MAX. Comment l'enlever, surligné en rouge)

mettre quelque part

if(price==DBL_MAX) price=0;

ou c'est possible directement dans le commentaire :

(price==DBL_MAX)?"нет ордера":DoubleToString(price,_Point)
 
Taras Slobodyanik #:

mettez-le quelque part

ou vous pouvez le mettre directement dans les commentaires :

J'aime la première option, pouvez-vous me donner un exemple de la façon de le faire correctement ?

 
makssub #:

J'aime la première option, pouvez-vous me donner un exemple de la façon de le faire correctement ?

double com_price=0;

if(UpPrice==DBL_MAX) com_price=0;
else com_price=UpPrice;

Comment(com_price);
 
MakarFX #:

merci, mais je ne comprends toujours pas comment le visser) aucune critique de mon travail ?

double FindPenultSellPrice() // а тут ищу предпоследний)
  {
   double oldticket, UpPrice = DBL_MAX;
   
   for(int cnt=OrdersTotal(); cnt>=0; cnt--)
   {
      if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL)
         {
            oldticket = OrderOpenPrice();
            if ( oldticket < UpPrice && MinOpenSell()< oldticket)
            {
               UpPrice = oldticket;
            }
         }
      }
   }
   return(UpPrice);
}
 
makssub #:

merci, mais je ne vois toujours pas comment le foirer) aucune critique de mon travail ?

Montrez-moi votre commentaire.

 
MakarFX #:

Montrez-moi votre commentaire.

J'ai déjà posté une photo. Et mon commentaire n'est pas déclaré à l'intérieur de la fonction.

Comment( " Количество открытых ордеров: ", CountTrades(),"\n" " Количество открытых ордеров Sell: ", FindLastSell(), "\n" " Количество открытых ордеров Buy: ", FindLastBuy(),
                "\n" " Общее количество открытых ордеров: ", OrdersTotal(),"\n" " Профит первого ордера Sell: " , FirstProfitSell(),
                "\n" " Профит первого ордера Buy: " ,FirstProfitBuy(), "\n" " Предпоследний ордер Buy: ",FindPenultBuyPrice(), "\n" " Предпоследний ордер Sell: ",FindPenultSellPrice());  
 
makssub #:

J'ai déjà posté une photo. Et le commentaire que j'ai n'est pas déclaré à l'intérieur de la fonction.

double com_price=0;
if(FindPenultSellPrice()==DBL_MAX) com_price=0;
else com_price=FindPenultSellPrice();
Comment( " Количество открытых ордеров: ", CountTrades(),"\n Количество открытых ордеров Sell: ", FindLastSell(),
       "\n Количество открытых ордеров Buy: ", FindLastBuy(),"\n Общее количество открытых ордеров: ", OrdersTotal(),
       "\n Профит первого ордера Sell: " , FirstProfitSell(),"\n Профит первого ордера Buy: " ,FirstProfitBuy(),
       "\n Предпоследний ордер Buy: ",FindPenultBuyPrice(), "\n Предпоследний ордер Sell: ",com_price);  
 

Bonjour à tous ! !!

J'écris le code d'un EA pour le Trailing Stop des ordres groupés à partir du prix moyen d'une grille d'ordres.

Aucune erreur dans le journal, mais le chalut ne fonctionne pas non plus. Voici le code, veuillez suggérer où se trouve l'erreur. Merci ! !!

//+----------------------------------------------------------------------------+
//| Модификация групповых ордеров                                              |
//+----------------------------------------------------------------------------+
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("Ошибка модификации ордеров!");
                TrailingGroupOrder();
           }
       }
    }
}
//+----------------------------------------------------------------------------+
//| Трейлинг стоп групповых ордеров                                            |
//+----------------------------------------------------------------------------+
void TrailingGroupOrder()
{
    price += OrderOpenPrice() * OrderLots();
    order_lots += OrderLots() ;
    for(int i = OrdersTotal()-1; i>=0; i--)
    {
     if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
       {
       if(OrderType() == OP_BUY && Bid - NormalizeDouble(price / order_lots, Digits) > TrailingStopGroupOrder)
        {
        if(Bid - NormalizeDouble(price / order_lots, Digits) > 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 && NormalizeDouble(price / order_lots, Digits)- Ask > TrailingStopGroupOrder*Point)
         {
         if( NormalizeDouble(price / order_lots, Digits)- 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("Ошибка модификации групповых ордеров на продажу!");
              }
           }
         }
      } 
    }
}
 
Bonjour ! Où puis-je trouver le code mql4 pour changer la langue dans la fenêtre des paramètres de l'EA ?