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

 
Fast235 #:

seule cette ligne soulève la question

-50 supplémentaires et un tableau

C'est pour dessiner au-dessus ou au-dessous de "0".

Mais vous pouvez vous en passer, j'ai besoin de l'essentiel, comment utiliser les poignées.

 
Vladimir Simakov #:

Je le recommande vivement :

Sinon, vous obtenez un oops.))

De plus, il faut le ramener à un tout juste après la division. Sinon, le comptage binaire peut faire beaucoup de choses).

 
MakarFX #:

Il s'agit de dessiner au-dessus ou au-dessous de "0".

mais vous pouvez vous en passer, je dois savoir comment utiliser les poignées.

un handle est un pointeur vers le fichier indicateur, il est généralement créé dans OnInit()

   Handle=iCustom(Symbol(),PERIOD_H1,"_iTrend",10);
//--- Если не удалось получить хендл индикатора
   if(Handle==INVALID_HANDLE)
     {
      PrintFormat("Failed to create handle of the iAO indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //---
      return(INIT_FAILED);
     }

plus loin dans le code

    if(CopyBuffer(Handle,0,1,1,Buffer1) <=0 проверка на ошибку
---
в Buffer1[1111] получаем значение
 
Fast235 #:

Handle est un pointeur vers le fichier indicateur, il est créé dans OnInit() généralement

plus loin dans le code

Merci, mais cela ressemble à l'aide et malheureusement ce n'est pas clair pour moi (

C'est pourquoi j'ai demandé de traduire mon code en mql5 afin de comprendre la logique du travail.

Je le fais de cette façon

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   prd = _Period > TimeFrame ? _Period : TimeFrame;
   atrHandle = iATR(_Symbol, prd, Per_Count);
   if(atrHandle == INVALID_HANDLE)
     {
      Print("Can't load indicator."); return INIT_FAILED;
     }
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,Label2Buffer,INDICATOR_DATA);
   
   ArraySetAsSeries(Label1Buffer, true);
   ArraySetAsSeries(Label2Buffer, true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int limit,i;
   int barPlus=iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_W1,WeekCount),false);
   limit=rates_total-prev_calculated-3;
   if(WeekCount!=0)limit=barPlus-1;
   if(limit<1) return(0);
   for(i=limit;i>=0;i--)
     {
      TimeToStruct(time[i],inTime);
      index01=iBarShift(_Symbol,PERIOD_D1,time[i],false);
      if(inTime.hour==0&&inTime.min==0)
        {
         Label1Buffer[i]=GetIndicator(atrHandle, index01+1);
        }
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
double GetIndicator(const int handle, const int i)
  {
   double res[1];
   if(CopyBuffer(handle, 0, i, 1, res) <= 0) return 0;
   return res[0];
  }
//+------------------------------------------------------------------+

Mais j'ai le sentiment que quelque chose ne va pas et que iMAOnArray n'est pas mentionné dans l'aide.

 

Bon après-midi.

Je ne peux pas résoudre le problème avec le looping Martin,

Je n'arrive pas à résoudre le problème du bouclage de la martin. elle se déconnecte après l'exécution :(n>=OrdersClose)- et ensuite la martin ne démarre pas jusqu'à ce qu'un trade profitable se produise,

J'ai besoin d'avoir unretour(dLots) après (n>=OrdersClose) et Martin recommencera si le prochain trade est à nouveau perdant.

Pourriez-vous me dire comment procéder ?

double LOT()
{
   int n=0;
   double OL=dLots;
   for (int j = OrdersHistoryTotal()-1; j >= 0; j--)
   {
      if (OrderSelect(j, SELECT_BY_POS,MODE_HISTORY))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == iMagic)
         {
            if (OrderProfit()<0) 
            {
               if (n==0) OL=NormalizeDouble(OrderLots()*K_Martin,DigitsLot);
               n++;
               if (n>=OrdersClose) {return(dLots);}
            }
            else
            {
               if (n==0) {return(dLots);}
               else {return(OL);}
            }
         }
      }
   }
   return(OL);
}
 

Bonne journée à tous ! !!

S'il vous plaît dites-moi s'il vous plaît dans la grille conseiller code prescrit l'affichage du prix moyen sur le graphique. Je serais d'accord, mais la ligne n'est pas correctement supprimée après la fermeture de la grille, c'est-à-dire que le prix moyen ne l'est pas. Veuillez me dire ce que j'ai fait de mal. Voici le code et l'image.

//+----------------------------------------------------------------------------+
//| Modifier les commandes groupées |
//+----------------------------------------------------------------------------+
void ModifyOrders(int otype)
{
double avg_price, AveragePriceBuy, AveragePriceSell, 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) ;
AveragePriceBuy = NormalizeDouble(avg_price + Spread, Digits) ;
AveragePriceSell = NormalizeDouble(avg_price - Spread, Digits) ;
{
ObjectDelete(0, "AveragePriceLine") ;
ObjectCreate("AveragePriceLine" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy) ;
ObjectCreate("AveragePriceLine" ,OBJ_HLINE, 0, 0 ,AveragePriceSell) ;
ObjectSet("AveragePriceLine",OBJPROP_COLOR,Blue) ;
}
if ((otype == OP_BUY) && (Drawdown <= DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceBuy + TakeProfitGroupOrder*Point, Digits) ;
if ((otype == OP_SELL) && (Drawdown <= DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceSell - TakeProfitGroupOrder*Point, Digits) ;
if ((otype == OP_BUY) && (Drawdown > DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceBuy, Digits) ;
if ((otype == OP_SELL) &/or& (Drawdown > DrawdownClosingTakeprofitZero))
tp = NormalizeDouble (AveragePriceSell, 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("Ordres modifiés avec succès !") ;
else Print("Error modifying orders !") ;
}
}
}
}


 
EVGENII SHELIPOV #:

Bonne journée à tous ! !!

Veuillez me conseiller dans le code du grid advisor prescrit l'affichage du prix moyen sur le graphique. Il serait OK, mais pas correctement supprimé la ligne après la fermeture de la grille, c'est-à-dire, le prix moyen n'est pas. S'il vous plaît dites-moi ce que j'ai fait mal. Voici le code et l'image.

Essayez comme ceci

//+----------------------------------------------------------------------------+
//| Модификация групповых ордеров                                              |
//+----------------------------------------------------------------------------+
void ModifyOrders(int otype)
{
    double avg_price, AveragePriceBuy, AveragePriceSell, 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);
    AveragePriceBuy = NormalizeDouble(avg_price + Spread, Digits);
    AveragePriceSell = NormalizeDouble(avg_price - Spread, Digits);
    if(ObjectFind(0,"AveragePriceLineBuy")==0)
     {
     ObjectDelete(0,"AveragePriceLineBuy");
     ObjectCreate(0,"AveragePriceLineBuy" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    else
     {
     ObjectCreate(0,"AveragePriceLineBuy" ,OBJ_HLINE, 0, 0 ,AveragePriceBuy);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    if(ObjectFind(0,"AveragePriceLineSell")==0)
     {
     ObjectDelete(0,"AveragePriceLineSell");
     ObjectCreate(0,"AveragePriceLineSell" ,OBJ_HLINE, 0, 0 ,AveragePriceSell);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    else
     {
     ObjectCreate(0,"AveragePriceLineSell" ,OBJ_HLINE, 0, 0 ,AveragePriceSell);
     ObjectSetInteger(0,"AveragePriceLine",OBJPROP_COLOR,Blue);
     }
    if ((otype == OP_BUY) && (Drawdown <= DrawdownClosingTakeprofitZero)) 
    tp = NormalizeDouble (AveragePriceBuy + TakeProfitGroupOrder*Point, Digits);
    if ((otype == OP_SELL) && (Drawdown <= DrawdownClosingTakeprofitZero))
    tp = NormalizeDouble (AveragePriceSell - TakeProfitGroupOrder*Point, Digits);
    if ((otype == OP_BUY) && (Drawdown > DrawdownClosingTakeprofitZero)) 
    tp = NormalizeDouble (AveragePriceBuy, Digits);
    if ((otype == OP_SELL) && (Drawdown > DrawdownClosingTakeprofitZero))
    tp = NormalizeDouble (AveragePriceSell, 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("Ошибка модификации ордеров!");
           }
       }
    }
}   

Ou mieux, prescrire,

s'il n'y a pas d'ordre de vente ouvert, supprimez la ligne de vente.

la même chose pour le bai

 
Bonsoir, comment réinitialiser l'état d'un bouton graphique lorsque vous cliquez dessus, afin qu'il ne soit pas enfoncé tout le temps jusqu'à ce que vous cliquiez à nouveau dessus ?
 
Nerd Trader #:
Bonsoir, comment réinitialiser l'état d'un bouton graphique lorsque vous cliquez dessus, afin qu'il ne soit pas enfoncé tout le temps jusqu'à ce que vous cliquiez à nouveau dessus ?
ObjectSetInteger(0,name,OBJPROP_STATE,false);
 
MakarFX #:
Non, vous vous trompez. J'ai besoin que l'état soit réinitialisé comme pour les boutons normaux après le relâchement du clic. Comment implémenter ceci si mql4 n'a pas d'événements d'état du bouton de la souris : clic/relâchement.
Raison: