Tutte le domande dei nuovi arrivati su MQL4 e MQL5, aiuto e discussione su algoritmi e codici - pagina 1398

 
Andrey Sokolov:

Grazie. Quindi questo è solo in mt5. Se qualcuno sa come aggiungere un indicatore da un EA, per favore fatemelo sapere

Puoi anche salvare Indicatori ed Esperto su un modello e come funziona la funzione - ti installerà un Esperto insieme agli Indicatori.

//+------------------------------------------------------------------+
//|                                                  DeleteChart.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property  show_inputs
//---
input string Template = "ADX"; // Имя шаблона(without '.tpl')
//---
ENUM_TIMEFRAMES TimeFrame; // Change TimeFrame - Current = dont changed
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   DeleteChart();
  }
//+------------------------------------------------------------------+
//| start function                                                   |
//+------------------------------------------------------------------+
void DeleteChart(void)
  {
   long currChart,prevChart=ChartFirst();
   int i=0,limit=100;
   bool errTemplate;
   while(i<limit)
     {
      currChart=ChartNext(prevChart);
      if(TimeFrame!=PERIOD_CURRENT)
        {
         ChartSetSymbolPeriod(prevChart,ChartSymbol(prevChart),TimeFrame);
        }
      errTemplate=ChartApplyTemplate(prevChart,Template+".tpl");
      if(!errTemplate)
        {
         Print("Error ",ChartSymbol(prevChart),"-> ",GetLastError());
        }
      if(currChart<0)
         break;
      Print(i,ChartSymbol(currChart)," ID =",currChart);
      prevChart=currChart;
      i++;
     }
  }
//+------------------------------------------------------------------+

documentazione mt4https://docs.mql4.com/ru/chart_operations/chartapplytemplate

documentazione mt5 https://www.mql5.com/ru/docs/chart_operations/chartapplytemplate

Документация по MQL5: Операции с графиками / ChartApplyTemplate
Документация по MQL5: Операции с графиками / ChartApplyTemplate
  • www.mql5.com
ChartApplyTemplate - Операции с графиками - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
SanAlex:

Puoi anche salvare Indicatori ed Expert su un modello e quando la funzione funziona ti installa un Expert insieme agli Indicatori.

documentazione mt4https://docs.mql4.com/ru/chart_operations/chartapplytemplate

documentazione mt5 https://www.mql5.com/ru/docs/chart_operations/chartapplytemplate

grazie per le risposte. Ma ne ho bisogno senza alcun preliminare.

 

Divertente inconveniente in MT4


Se si crea un duplicato di un oggetto in un grafico utilizzando il pulsante cntrl premuto, l'evento id == CHARTEVENT_OBJECT_CREATE viene catturato in Expert Advisor

Se elimino questo oggetto dall'Expert Advisor, appare l'errore 4202 - Object does not exist. Allo stesso tempo, l'oggetto è già sul grafico.


Cosa fare? Come faccio a cancellare l'oggetto?

   if(id == CHARTEVENT_OBJECT_CREATE)
     {
      Print("New object create", sparam);
      if(!ObjectDelete(sparam))
       {
          Print(" error remove ", GetLastError(), " ",sparam);    //здесь будет ошибка 4202.  Хотя это событие срабатывает когда объект есть на графике! 
       }
}
 
Andrey Sokolov:

Grazie per le risposte. Ma dovete farlo senza alcun preliminare.

In primo luogo, si prende l'indicatore richiesto e gli si aggiungono i parametri necessari - periodo, TF, larghezza della linea, colore della linea, ecc.

Lo salvi con un nome diverso. Compilare. Nell'Expert Advisor in OnInit() o in qualsiasi altro posto (non in OnTick()) aggiungete il vostro indicatore

handle_newInd = iCustom(Symbol(),Period(),"my_Ind\\new_xxxxx",in_period,in_size,in_from,.....);
   if(handle_newCandles == INVALID_HANDLE)
   {
      return(INIT_FAILED);
   }
   ChartIndicatorAdd(0,1,handle_newInd);
 
Сергей Таболин:

Per prima cosa prendete l'indicatore richiesto e aggiungete i parametri necessari al suo input - periodo, timeframe, larghezza della linea, colore della linea, ecc.

Salvarlo con un nome diverso. Compilare. Nell'Expert Advisor in OnInit() o in qualsiasi altro posto (non in OnTick()) aggiungete il vostro indicatore

MT4 deve!
 
Sergey Likho:

Divertente inconveniente in MT4


Se si crea un duplicato di un oggetto in un grafico usando il pulsante cntrl premuto, l'evento id == CHARTEVENT_OBJECT_CREATE viene catturato in Expert Advisor

Se elimino questo oggetto dall'Expert Advisor, appare l'errore 4202 - Object does not exist. Allo stesso tempo, l'oggetto è già sul grafico.


Cosa fare? Come faccio a cancellare l'oggetto?

Questo non è un glitch, è una caratteristica)
L'utente sta tenendo l'oggetto con il mouse - non può essere cancellato.

Aspettate che il pulsante del mouse venga rilasciato e poi cancellatelo.

 
Taras Slobodyanik:

questo non è un glitch ma una caratteristica)
l'utente sta tenendo un oggetto con il mouse - non c'è modo di cancellarlo.

Aspettate che il pulsante del mouse venga rilasciato e poi cancellate.

Grazie mille! È davvero un bug)) L'ho capito. Ora tutto funziona!

 
Ciao a tutti!
che può aiutare a modificare il codice di un indicatore...
1. Invertire il fibo, cioè il fibo è allungato verso il bastone a zigzag formato
2. Aggiungere un parametro nelle impostazioni per impostare l'allerta ad un livello specificato...., cioè specifico manualmente il livello a cui voglio che ronzi e mostri il punto di allerta...
Dovrebbe essere qualcosa come 1-2-3



Grazie in anticipo ....

Esempio sullo screenshot, codice allegato....

//+------------------------------------------------------------------+
//|                                                                  |
//|                 Copyright © 2000-2007, MetaQuotes Software Corp. |
//|                                         http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// 
// 2009.12 - добавлены фибо уровни, "nen"(ом) c форума MQL

#property copyright ""
#property link "ххххх"
#property link "ххххх"
#property description "ххххх"
#property strict

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDarkGray
#property indicator_color2 clrRed
#property indicator_width2 3

//----
extern int    Length          = 6;           // Length
extern int    CountBars       = 300;        // History
extern bool   fibo            = true;        // Use FIBO
extern color  colorFibo       = clrSkyBlue;  // Color FIBO
extern bool   AlertsMessage   = true;        // Alert Message
extern bool   AlertsSound     = false;       // Alert Sound
extern bool   AlertsEmail     = false;       // Alert Email
extern bool   AlertsMobile    = false;       // Alert Mobile
extern string AlertsSoundFile = "alert.wav"; // Alert Sound File
//----
double buffer[];
double lBar, hBar;
datetime tiZZ;
double p1,p2;
datetime t1,t2;
double   fi_1[]={0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.0, 1.272, 1.5, 1.618, 1.854, 2.0, 2.618, 3.5, 4.618, 5.618, 6.854};
string   fitxt100_1[]={"0.0", "23.6", "38.2", "50.0", "61.8", "78.6", "100.0", "127.2", "150.0", "161.8", "185.4", "200.0", "261.8", "350.0", "461.8", "561.8", "685.4"};
int Sizefibo;
string TF[]={"MN","W1","D1","H4","H1","m30","m15","m5","m1"};
string Period_tf;
double Arr[];
int LastSwing;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void init()
  {
   SetIndexStyle (0,DRAW_SECTION,0,1);
   SetIndexBuffer(0,buffer);
   SetIndexLabel (0,"Value");
   SetIndexDrawBegin(0,0);
   
   SetIndexStyle (1,DRAW_ARROW);
   SetIndexBuffer(1,Arr);
   SetIndexArrow (1,159);
   SetIndexLabel (1,"Arr");

   
   Sizefibo=ArraySize(fi_1);
   switch (Period())
     {
      case 1     : {Period_tf=TF[8];break;}
      case 5     : {Period_tf=TF[7];break;}
      case 15    : {Period_tf=TF[6];break;}
      case 30    : {Period_tf=TF[5];break;}
      case 60    : {Period_tf=TF[4];break;}
      case 240   : {Period_tf=TF[3];break;}
      case 1440  : {Period_tf=TF[2];break;}
      case 10080 : {Period_tf=TF[1];break;}
      case 43200 : {Period_tf=TF[0];break;}
     }
    LastSwing = 0;
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function. Начало.              |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("_%fibo");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function. Конец.               |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void start()
  {
   int shift, zu, zd, Swing, Swing_n, i, i1=0, i2=0;
   double HH, LL, BH, BL;
//----
   if (tiZZ!=Time[0] || lBar<Low[0] || hBar>High[0]) // micmed+nen
     {
      tiZZ=Time[0]; lBar=Low[0]; hBar=High[0];
      if ((Bars-IndicatorCounted()-1)>2) ArrayInitialize(buffer,EMPTY_VALUE);
     }
   else return;

   Swing=0;
   Swing_n=0;
   shift=CountBars-1;
   zu=shift;
   zd=shift;
   BH=High[shift];
   BL=Low[shift];
//----
   for(shift=CountBars-1; shift>=0; shift--)
     {
      HH=High[Highest(NULL,0,MODE_HIGH,Length,shift+1)];
      LL=Low [Lowest (NULL,0,MODE_LOW ,Length,shift+1)];
      if (Low[shift]<LL && High[shift]>HH)
        {
         Swing=2;
         if (Swing_n== 1) zu=shift+1;
         if (Swing_n==-1) zd=shift+1;
        }
      else
        {
         if (Low [shift]<LL) Swing=-1;
         if (High[shift]>HH) Swing= 1;
        }
      if (Swing!=Swing_n && Swing_n!=0)
        {
         if (Swing== 2) {Swing=-Swing_n; BH=High[shift]; BL=Low[shift];}
         if (Swing== 1) {buffer[zd]=BL; i1=i2; i2=zd;}
         if (Swing==-1) {buffer[zu]=BH; i1=i2; i2=zu;}
         BH=High[shift];
         BL=Low [shift];
        }
      if (Swing== 1) {if (High[shift]>=BH) {BH=High[shift]; zu=shift;}}
      if (Swing==-1) {if (Low [shift]<=BL) {BL=Low [shift]; zd=shift;}}
      Swing_n=Swing;
     }
   
    if(LastSwing!=Swing) 
     {
       if(LastSwing!=0)
        { 
          if(AlertsMessage || AlertsEmail || AlertsMobile || AlertsSound)
           {
             string message = (WindowExpertName()+" - "+Symbol()+"  "+PeriodString()+" - Change FIBO");

             if (AlertsMessage) Alert(message);
             if (AlertsEmail)   SendMail(Symbol()+" - "+WindowExpertName()+" - ",message);
             if (AlertsMobile)  SendNotification(message);
             if (AlertsSound)   PlaySound(AlertsSoundFile);
           }
        
          Arr[0] = Close[0]; 
        } 
       LastSwing = Swing;
     }  

   if (fibo)
     {
      p1=buffer[i1]; t1=Time[i1];
      p2=buffer[i2]; t2=Time[i2];

      string nameObj="_%fibo";        
      ObjectDelete(nameObj);
      ObjectCreate(nameObj,OBJ_FIBO,0,t1,p1,t2,p2);

      ObjectSet(nameObj,OBJPROP_LEVELCOLOR,colorFibo);

      ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE);
      ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT);
      ObjectSet(nameObj,OBJPROP_WIDTH,0);
      ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DOT);
      ObjectSet(nameObj,OBJPROP_LEVELWIDTH,0);
      ObjectSet(nameObj,OBJPROP_BACK,true);

      ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefibo);
      for (i=0;i<Sizefibo;i++)
        {
         ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+i,fi_1[i]);
         ObjectSetFiboDescription(nameObj, i, fitxt100_1[i]+" "+DoubleToStr((p1-p2)*fi_1[i]+p2, Digits)+"-"+Period_tf); 
        }
     }

  }
//+------------------------------------------------------------------+
//| Period String                                                    |
//+------------------------------------------------------------------+
string PeriodString()
  {
    switch (_Period) 
     {
        case PERIOD_M1:  return("M1");
        case PERIOD_M5:  return("M5");
        case PERIOD_M15: return("M15");
        case PERIOD_M30: return("M30");
        case PERIOD_H1:  return("H1");
        case PERIOD_H4:  return("H4");
        case PERIOD_D1:  return("D1");
        case PERIOD_W1:  return("W1");
        case PERIOD_MN1: return("MN1");
        default: return("M"+(string)_Period);
     }  
    return("M"+(string)_Period); 
  }
//+------------------------------------------------------------------+
Документация по MQL5: Сетевые функции / SendNotification
Документация по MQL5: Сетевые функции / SendNotification
  • www.mql5.com
SendNotification - Сетевые функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
File:
kyucri.jpg  102 kb
 
btc.mmd:
Ciao a tutti!
può aiutarmi a sistemare l'indicatore
1. Girare il fibo, cioè il fibo è allungato verso lo stick zigzag formato
2. Aggiungere il parametro "set allert to a specified level....", cioè indico manualmente il livello al quale voglio che ronzi e mostri il punto di allerta...

Dovrebbe risultare qualcosa come 1-2-3

Grazie in anticipo ....

Esempio sullo screenshot, codice allegato....




//+------------------------------------------------------------------+
//| |
//| Copyright © 2000-2007, MetaQuotes Software Corp.
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// ххххххх
// 2009.12 - aggiunti livelli Fibo, "nen" dal forum MQL.

#proprietà copyright ""
#proprietà link "ххххх"
#proprietà link "xxxxxx"
#descrizione della proprietà "xxxxxxxxxx"
#proprietà rigorosa

Per cominciare, rimuovi il tuo spoofing e incolla il codice in modo umano.

//+------------------------------------------------------------------+
//|                                                                  |
//|                 Copyright © 2000-2007, MetaQuotes Software Corp. |
//|                                         http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// хххххххххххх
// 2009.12 - добавлены фибо уровни, "nen"(ом) c форума MQL.

#property copyright ""
#property link "ххххх"
#property link "хххххх"
#property description "ххххххххх"
#property strict
 

Ciao gente!

Puoi dirmi perché non viene visualizzato nulla sul grafico quando metti questo indicatore?

Si compila senza errori, rsi_channel è nella cartella...non capisco(

File: