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

 
He encontrado un nuevo indicador, quería ponerlo en mi EA, pero el problema es que abre operaciones en cada vela. ¿Puedes decirme cómo hacer que se abra sólo con la señal de la flecha?
//------------------------------------------------------------------
#property copyright "Hill"
#property link      "Romio.com"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Orange
#property indicator_color2 DarkGray
#property indicator_color3 Orange
#property indicator_color4 LimeGreen
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
#property indicator_style4 STYLE_DOT
//

//
//
//
//
//

extern int    RsiLength  = 4;
extern int    RsiPrice   = PRICE_CLOSE;
extern int    HalfLength = 5;
extern int    DevPeriod  = 100;
extern int    Sise       = 10;
extern double Deviations = 1.0;
extern bool   UseAlert   = true;
extern bool   DrawArrows = true;

color ColorDn = Crimson;
color ColorUp = DodgerBlue;
int     CodDn = 222;
int     CodUp = 221;

string   Font = "Verdana";

// ti init() if(ObjectFind("100s")<0)GetText(3,"100s","BuySell Pro",LawnGreen,5,5,7);


string PrefixArrow = "ArrowsHill";

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];

double up[];
double dn[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   HalfLength=MathMax(HalfLength,1);
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);

   SetIndexStyle(4,DRAW_ARROW,0,2,Blue);
   SetIndexArrow(4,233);
   SetIndexBuffer(4,up);

   SetIndexStyle(5,DRAW_ARROW,0,2,Red);
   SetIndexArrow(5,234);
   SetIndexBuffer(5,dn);


   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   DellObj(PrefixArrow);

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,k,counted_bars=IndicatorCounted();
   if(counted_bars<0)
      return(-1);
   if(counted_bars>0)
      counted_bars--;
   int limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

   static datetime timeLastAlert = NULL;

   for(i=limit; i>=0; i--)
      buffer1[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
   for(i=limit; i>=0; i--)
     {
      double dev  = iStdDevOnArray(buffer1,0,DevPeriod,0,MODE_SMA,i);
      double sum  = (HalfLength+1)*buffer1[i];
      double sumw = (HalfLength+1);
      for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
        {
         sum  += k*buffer1[i+j];
         sumw += k;
         if(j<=i)
           {
            sum  += k*buffer1[i-j];
            sumw += k;
           }
        }
      buffer2[i] = sum/sumw;
      buffer3[i] = buffer2[i]+dev*Deviations;
      buffer4[i] = buffer2[i]-dev*Deviations;

      if(buffer1[i] >= buffer3[i] /*&& buffer1[i+1] < buffer3[i+1]*/)
        {
         dn[i] = buffer3[i];
         if(DrawArrows)
            ArrowDn(Time[i], High[i]);

         if(UseAlert && i == 0 && Time[0] != timeLastAlert)
           {
            Alert("Signal DOWN!");
            timeLastAlert = Time[0];
           }
        }

      if(buffer1[i] <= buffer4[i] /*&& buffer1[i+1] > buffer4[i+1] */)
        {
         up[i] = buffer4[i];
         if(DrawArrows)
            ArrowUp(Time[i], Low[i]);

         if(UseAlert && i == 0 && Time[0] != timeLastAlert)
           {
            Alert("Signal UP!");
            timeLastAlert = Time[0];
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ArrowUp(datetime tim,double pr)
  {
   if(ObjectFind(PrefixArrow+"TextUp"+tim)==-1)
     {
      if(ObjectCreate(PrefixArrow+"TextUp"+tim,OBJ_TEXT,0,tim,pr-GetDistSdvig()))
         ObjectSetText(PrefixArrow+"TextUp"+tim,CharToStr(CodUp),Sise,"WingDings",ColorUp);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ArrowDn(datetime tim,double pr)
  {
   if(ObjectFind(PrefixArrow+"TextDn"+tim)==-1)
     {
      if(ObjectCreate(PrefixArrow+"TextDn"+tim,OBJ_TEXT,0,tim,pr+GetDistSdvig()))
         ObjectSetText(PrefixArrow+"TextDn"+tim,CharToStr(CodDn),Sise,"WingDings",ColorDn);
     }
  }
extern double TextSdvigMnoj = 2;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetDistSdvig()
  {
   return(iATR(NULL, 0, 100, 1) * TextSdvigMnoj);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DellObj(string dell)
  {
   string name;
   for(int i = ObjectsTotal()-1 ; i >=0 ; i--)
     {
      name = ObjectName(i);
      if(StringFind(name, dell) != EMPTY)
         ObjectDelete(name);
     }
  }
//+------------------------------------------------------------------+
Archivos adjuntos:
 
jarikn:
Encontré un nuevo indicador, quería ponerlo en el EA, pero el problema es que abre operaciones en cada vela. Por favor, aconsejar cómo hacer que se abra sólo en la señal de flecha

En primer lugar, el indicador no es nuevo en absoluto, sino muy antiguo. Tan antiguo que sus interfaces son obsoletas incluso para 4

En segundo lugar, se redibuja. Exactamente a la mitad de la longitud (5 barras por defecto, ajustadas en los parámetros)

y finalmente - cómo abrir operaciones para el Asesor Experto depende en un 90% del EA, es decir, sin el código del EA, todo es inútil

 
Maxim Kuznetsov:

En primer lugar, el indicador no es nuevo en absoluto, sino muy antiguo. Tan antiguo que sus interfaces son obsoletas incluso para 4

En segundo lugar, se redibuja. Exactamente a la mitad de la longitud (5 barras por defecto, ajustadas en los parámetros)

Y por último - cómo abrir operaciones para el Asesor Experto depende en un 90% del EA, es decir, sin el código del EA, todo es inútil

Ok. Lo tengo. Por ejemplo, si tomamos 2 indicadores con diferentes periodos y escribimos la condición *si 1 indicador muestra la flecha hacia arriba y 2 indicadores muestran la flecha hacia arriba en una vela, nos da una alerta y una flecha en el gráfico*. ¿Sabe cómo se puede aplicar esto? ¿Necesito añadir un buffer o puedo crear un indicador que siga las señales de ambos? Y si no eres duro, pon un ejemplo de cómo hacerlo

 
jarikn:

Vale. Lo tengo. Por ejemplo, si tomamos 2 indicadores con diferentes períodos y escribimos la siguiente condición *si 1 indicador muestra la flecha hacia arriba y 2 indicadores muestran la flecha hacia arriba en una vela, entonces nos da una alerta y una flecha en el gráfico*. ¿Sabe cómo se puede aplicar esto? ¿Necesito añadir un buffer o puedo crear un indicador que siga las señales de ambos? Y si no eres duro, pon un ejemplo de cómo hacerlo

Añade dos iCustom con diferentes periodos a tu Expert Advisor y (quizás) estarás contento.
 
MakarFX:
Añade dos iCustom con diferentes periodos a tu EA y (quizás) serás feliz.

Bien, lo intentaré. Gracias.

 

Hola de nuevo )))) ¿Quién puede decirme cuál es el indicador?

Archivo <*.ex* borrado

 

Estoy tratando de escribir un indicador como ZigZag por el número de puntos pasados.

Me temo que no tengo suficientes conocimientos para escribirlo yo mismo, así que he decidido reescribir el indicador de otra persona.

Esto es lo que tengo.

#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_SECTION
#property indicator_color1  clrCrimson
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input int      Points=50;
//--- indicator buffers
int Trend=1,InTrend;
datetime ttime;
double Last_High,Last_Low;
double Buffer01[],Buffer02[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorBuffers(2);
   IndicatorDigits(Digits);
//--- indicator buffers mapping
   SetIndexBuffer(0,Buffer01);
   SetIndexBuffer(1,Buffer02);
   SetIndexEmptyValue(0,0);
//---
   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=rates_total-prev_calculated-2;
   if(limit<2) return(0);
   for(int i=limit; i>=0;i--)
     {
      if(time[i]!=ttime) {InTrend=InTrend+1; ttime=time[i];}
      Buffer01[i]=0;
      Buffer02[i]= open[i]; 
      if(Buffer02[i+1]>Last_High && Trend==1)   InTrend=1;
      if(Buffer02[i+1]<Last_Low  && Trend==0)   InTrend=1;
      if(Buffer02[i+1]>Last_High) Last_High=Buffer02[i+1];
      if(Buffer02[i+1]<Last_Low ) Last_Low =Buffer02[i+1];
      //----
      if(Trend==1 && Buffer02[i+1]<Last_High-Points*Point && InTrend>1)
        {
         Trend=0;
         if(i+InTrend<ArraySize(Buffer01))
         Buffer01[i+InTrend]=Buffer02[i+InTrend];
         Last_High=Buffer02[i+1];
         Last_Low=Buffer02[i+1];
         InTrend=1;
        }
      if(Trend==0 && Buffer02[i+1]>Last_Low+Points*Point && InTrend>1)
        {
         Trend=1;
         if(i+InTrend<ArraySize(Buffer01))
         Buffer01[i+InTrend]=Buffer02[i+InTrend];
         Last_Low=Buffer02[i+1];
         Last_High=Buffer02[i+1];
         InTrend=1;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Parece que se dibuja correctamente, pero se retrasa.

El precio ha superado los 50 puntos pero el indicador no dibuja.

Por favor, ayúdenme a solucionar este problema.

 
MakarFX:

Ayude a resolver el problema, por favor.

aquí está el punto por punto zz para mt5

https://www.mql5.com/ru/forum/318267#comment_12508440


debería funcionar en MT4 si se cambia la numeración en el ciclo de cálculo principal

 
Igor Makanu:

aquí está el punto por punto ZZ publicado para mt5

https://www.mql5.com/ru/forum/318267#comment_12508440


Debería funcionar en MT4 si se renumera el ciclo de cálculo principal

Igor, gracias, pero MT4 no funciona correctamente.


Por favor, dígame qué tiene que ser correcto.

 
Me he encontrado con un problema de este tipo. He puesto el indicador mt2 en mt4. se supone que lee los buffers del indicador y cuando aparece la flecha debería abrir automáticamente operaciones en opciones binarias. pero el problema es que lo tengo abriendo operaciones cada nueva vela y sólo al alza. ¿Quién sabe qué pasa?
Archivos adjuntos:
Screenshot_8.png  121 kb
123.mq4  5 kb
Razón de la queja: