Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 1398

 
Andrey Sokolov:

Gracias. Así que es sólo en mt5. Si alguien sabe cómo añadir un indicador de un EA, por favor hágamelo saber

También puede guardar los Indicadores y el Experto en una plantilla y como la función funciona - le instalará un Experto junto con los Indicadores.

//+------------------------------------------------------------------+
//|                                                  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++;
     }
  }
//+------------------------------------------------------------------+

documentación de mt4https://docs.mql4.com/ru/chart_operations/chartapplytemplate

documentación de mt5 https://www.mql5.com/ru/docs/chart_operations/chartapplytemplate

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

También puede guardar los Indicadores y el Experto en una plantilla y cuando la función funcione le instalará un Experto junto con los Indicadores.

documentación de mt4https://docs.mql4.com/ru/chart_operations/chartapplytemplate

documentación de mt5 https://www.mql5.com/ru/docs/chart_operations/chartapplytemplate

Gracias por las respuestas. Pero lo necesito sin ningún tipo de preliminares.

 

Divertido fallo en MT4


Si se crea un duplicado de un objeto en un gráfico utilizando el botón cntrl pulsado, el evento id == CHARTEVENT_OBJECT_CREATE se captura en el Asesor Experto

Si elimino este objeto del Asesor Experto, aparecerá el error 4202 - El objeto no existe. Al mismo tiempo, el objeto ya está en la carta.


¿Qué hacer? ¿Cómo puedo eliminar el objeto?

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

Gracias por las respuestas. Pero tienes que hacerlo sin ningún tipo de preliminares.

En primer lugar, se toma el indicador deseado y se le añaden los parámetros que se necesitan: periodo, TF, anchura de línea, color de línea, etc.

Lo guardas con un nombre diferente. Compílalo. En el Asesor Experto en OnInit() o en cualquier otro lugar (no en OnTick()) añada su indicador

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);
 
Сергей Таболин:

En primer lugar, se toma el indicador deseado y se añaden los parámetros necesarios a su entrada: período, TF, grosor de la línea, color, etc.

Guárdalo con otro nombre. Compílalo. En el Asesor Experto en OnInit() o en cualquier otro lugar (no en OnTick()) añada su indicador

¡MT4 debe!
 
Sergey Likho:

Divertido fallo en MT4


Si se crea un duplicado de un objeto en un gráfico utilizando el botón cntrl pulsado, el evento id == CHARTEVENT_OBJECT_CREATE se captura en el Asesor Experto

Si elimino este objeto del Asesor Experto, aparecerá el error 4202 - El objeto no existe. Al mismo tiempo, el objeto ya está en la carta.


¿Qué hacer? ¿Cómo puedo eliminar el objeto?

Esto no es un fallo, es una característica)
El usuario está sujetando el objeto con el ratón - no se puede borrar.

Espere a soltar el botón del ratón y luego elimínelo.

 
Taras Slobodyanik:

esto no es un fallo sino una característica)
el usuario está sujetando un objeto con el ratón - no hay manera de borrarlo.

Espere a que se suelte el botón del ratón y luego borre.

¡Muchas gracias! Realmente es un error)) Lo he resuelto. Ahora todo funciona.

 
Hola a todos!
que puede ayudar a ajustar el código de un indicador...
1. Invertir el fibo, es decir, el fibo se estira hacia el palo formado en zigzag
2. Añadir un parámetro en los ajustes para establecer el allert a un nivel especificado...., es decir, especifico manualmente el nivel al que quiero que suene y muestre el punto de allert...
Debería resultar algo así como 1-2-3



Gracias de antemano ....

Ejemplo en la captura de pantalla, código adjunto....

//+------------------------------------------------------------------+
//|                                                                  |
//|                 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
Archivos adjuntos:
kyucri.jpg  102 kb
 
btc.mmd:
Hola a todos!
puede ayudarme a arreglar el indicador
1. Girar el fibo, es decir, el fibo se estira hacia el palo formado en zigzag
2. Añadir el parámetro "set allert to a specified level....", es decir, indicar manualmente el nivel al que quiero que suene y mostrar el punto de allert...

Debería resultar algo así como 1-2-3

Gracias de antemano ....

Ejemplo en la captura de pantalla, código adjunto....




//+------------------------------------------------------------------+
//| |
//| Copyright © 2000-2007, MetaQuotes Software Corp.
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
// хххххххххх
// 2009.12 - añadido niveles de Fibo, "nen"(por) del foro MQL.

#property copyright ""
#enlace de propiedad "хххххх"
#enlace de propiedad "xxxxxx"
#descripción de la propiedad "xxxxxxxxxx"
#propiedad estricta

Para empezar, elimina el spoofing y pega el código de forma humana.

//+------------------------------------------------------------------+
//|                                                                  |
//|                 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
 

¡Hola amigos!

¿Puedes decirme por qué no se muestra nada en el gráfico cuando pones este indicador?

Compila sin errores, rsi_channel está en la carpeta...no entiendo(

Archivos adjuntos:
Razón de la queja: