Errores, fallos, preguntas - página 2504

 
Francuz:
Gente, compartid algo de información. ¿Para qué utiliza la alineación?

¡esto es programación orientada a los mapaches!

Por desgracia, no se puede prescindir de él ;)

 
Igor Makanu:

¡esto es programación orientada a los mapaches!

Por desgracia, no se puede prescindir de él ;)

Soy consciente de ello. No te pido que me enseñes sobre POO. He preguntado quién utiliza la alineación para qué.

 
Francuz:
Gente, ¿pueden compartir alguna información? ¿Para qué utiliza la alineación?

Todo esto es muy útil en un entorno multihilo, yo lo veo así. ¿Qué tiene que ver MKL con esto? No sé, la pregunta estaba hecha, así que me quedé atascado.

Y en general - estos son los fundamentos, una comprensión básica es necesaria para cualquier programador decente.

ZS: Bueno, aquí hay muchos fanáticos de la velocidad, si empiezan a alinear todo de forma inteligente, deberían volar aún más rápido, en teoría al menos.
 
Francuz:
Gente, compartid algo de información. ¿Para qué utiliza la alineación?
Puede ser necesario cuando se transfieren estructuras a bibliotecas externas.
 

Vict:

ZS: bueno, hay muchos aficionados a la velocidad aquí, si empiezan a hacerlo bien, debería ir aún más rápido, en teoría al menos.


En general, ni siquiera me lo esperaba:

#define  WRONG_ALIGNED
#define  CACHE_LINE_SIZE 64

struct Data {
#ifdef  WRONG_ALIGNED
   short bad_pad;
#endif
   uint ar[CACHE_LINE_SIZE/sizeof(int)];
};

#import "msvcrt.dll"
  long memcpy(Data &, Data &, long);
#import
#define  getaddr(x) memcpy(x, x, 0)

void OnStart()
{
   Data data[32768];
   if (getaddr(data[0])%4 != 0) {
      Alert("error");
      return;
   }
   ZeroMemory(data);
   int index = int(CACHE_LINE_SIZE - getaddr(data[0]) % CACHE_LINE_SIZE) / sizeof(int) - 1;
   
   srand(GetTickCount());
   
   ulong start_time = GetMicrosecondCount();
   for(unsigned i = 0; i < 10000; ++ i) {
      int rndnum = rand();
      while (++rndnum < 32768)
         for (int j = ArraySize(data[rndnum].ar)-1; j >= 0;  -- j)
            ++ data[rndnum].ar[j];
   }
      
   Alert(GetMicrosecondCount() - start_time);
   
   for (int j = ArraySize(data[100].ar)-1; j >= 0;  -- j)
      Print(data[100].ar[j]);
}
/*
WRONG_ALIGNED:
6117940
6104068
6047416

RIGHT_ALIGNED
3341823
2565150
2565150
*/

El código es un poco sobrecomplicado - traté de golpear ese elemento que no cabe en la línea de caché y golpear directamente en él, pero falló (probablemente se podría hacer si quisiera, pero me aburrí), y no cambié mucho el código. Pero esto es aún más impresionante - sólo uno de los 16 colapsos se hace sobre el elemento que no cae en la línea de caché, sin embargo, da un resultado sensible.

SZY: más objetivamente en este caso para hacer RIGHT_ALIGNED mediante la inserción de dos cortos, en lugar de eliminar única (por lo que vamos a lograr dos actualizaciones de la línea de caché para ambos casos). El aumento de velocidad será más modesto, pero aún así se multiplicará por 1,5.

 

Por cierto, en mql el valor por defecto de pack es 1, más o menos.

A juzgar por el post anterior, tal vez tenga sentido prescribir 8 explícitamente a todas las estructuras y clases.

 

No puedo superar el error.

Tomé el zigzag de la entrega de Metatrader para demostrar el error. Se han añadido búferes adicionales al código, tomados de mi programa. En este código no se pretende realizar manipulaciones con búferes adicionales. Son sólo para demostrar el error.

Trazado de este zigzag en el marco de tiempo EURUSD H1. Cerró la terminal. Se han eliminado del historial todas las series temporales generadas para el EURUSD. Es decir, borró todos los archivos *.hcc y *.hc del par de divisas EURUSD. Se ha hecho para asegurar la carga de archivos .hcc y la generación de archivos .hc a partir de una hoja limpia.

Después de iniciar el terminal, verá un montón de artefactos en el gráfico del EURUSD. Estos artefactos no pueden ser tratados.

Adjunto el código modificado del zigzag en forma de texto y en forma de archivo.

Quiero advertir que los parámetros del zigzag se especifican a través de #propert.

Todos los demás búferes no se establecen a través de #propert, porque todo, incluyendo los búferes de zigzag, se cambian dinámicamente.

//+------------------------------------------------------------------+
//|                                                       ZigZag.mq5 |
//|                   Copyright 2009-2017, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 29
#property indicator_plots 17
//---- plot Zigzag

#property  indicator_label17  "Zigzag"
#property  indicator_type17   DRAW_SECTION
#property  indicator_color17  Red
#property  indicator_style17  STYLE_SOLID
#property  indicator_width17  1

//--- input parameters
input int      ExtDepth=12;
input int      ExtDeviation=5;
input int      ExtBackstep=3;
//--- indicator buffers
double         ZigzagBuffer[];      // main buffer
double         HighMapBuffer[];     // highs
double         LowMapBuffer[];      // lows
int            level=3;             // recounting depth
double         deviation;           // deviation in points

double Hmzz1[],      Hmzz2[],  Hmzz3[], Hmzz4[],     Hmzz5[],   Hmzz6[], Hmzz7[], Hmzz8[],      Hmzz9[],  Hmzz10[];
double Lmzz1[],      Lmzz2[],  Lmzz3[], Lmzz4[],     Lmzz5[],   Lmzz6[], Lmzz7[], Lmzz8[],      Lmzz9[],  Lmzz10[];
double nen_ZigZagL[], nen_ZigZagH[];
double ha[], la[], ham[], lam[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

   SetIndexBuffer(0,Lmzz1,INDICATOR_DATA);   // Plot = 0
   SetIndexBuffer(1,Hmzz1,INDICATOR_DATA);
   SetIndexBuffer(2,Lmzz2,INDICATOR_DATA);   // Plot = 1
   SetIndexBuffer(3,Hmzz2,INDICATOR_DATA);
   SetIndexBuffer(4,Lmzz3,INDICATOR_DATA);   // Plot = 2
   SetIndexBuffer(5,Hmzz3,INDICATOR_DATA);
   SetIndexBuffer(6,Lmzz4,INDICATOR_DATA);   // Plot = 3
   SetIndexBuffer(7,Hmzz4,INDICATOR_DATA);
   SetIndexBuffer(8,Lmzz5,INDICATOR_DATA);   // Plot = 4
   SetIndexBuffer(9,Hmzz5,INDICATOR_DATA);
   SetIndexBuffer(10,Lmzz6,INDICATOR_DATA);   // Plot = 5
   SetIndexBuffer(11,Hmzz6,INDICATOR_DATA);
   SetIndexBuffer(12,Lmzz7,INDICATOR_DATA);   // Plot = 6
   SetIndexBuffer(13,Hmzz7,INDICATOR_DATA);
   SetIndexBuffer(14,Lmzz8,INDICATOR_DATA);   // Plot = 7
   SetIndexBuffer(15,Hmzz8,INDICATOR_DATA);
   SetIndexBuffer(16,Lmzz9,INDICATOR_DATA);   // Plot = 8
   SetIndexBuffer(17,Hmzz9,INDICATOR_DATA);
   SetIndexBuffer(18,Lmzz10,INDICATOR_DATA);   // Plot = 9
   SetIndexBuffer(19,Hmzz10,INDICATOR_DATA);
   
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(8,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(9,PLOT_EMPTY_VALUE,0.0);

   ArraySetAsSeries(Lmzz1,true);
   ArraySetAsSeries(Hmzz1,true);
   ArraySetAsSeries(Lmzz2,true);
   ArraySetAsSeries(Hmzz2,true);
   ArraySetAsSeries(Lmzz3,true);
   ArraySetAsSeries(Hmzz3,true);
   ArraySetAsSeries(Lmzz4,true);
   ArraySetAsSeries(Hmzz4,true);   
   ArraySetAsSeries(Lmzz5,true);
   ArraySetAsSeries(Hmzz5,true);
   ArraySetAsSeries(Lmzz6,true);
   ArraySetAsSeries(Hmzz6,true);
   ArraySetAsSeries(Lmzz7,true);
   ArraySetAsSeries(Hmzz7,true);
   ArraySetAsSeries(Lmzz8,true);
   ArraySetAsSeries(Hmzz8,true);
   ArraySetAsSeries(Lmzz9,true);
   ArraySetAsSeries(Hmzz9,true);
   ArraySetAsSeries(Lmzz10,true);
   ArraySetAsSeries(Hmzz10,true);
   ArraySetAsSeries(nen_ZigZagH,true);
   ArraySetAsSeries(nen_ZigZagL,true);
   ArraySetAsSeries(ham,true);
   ArraySetAsSeries(lam,true);
   ArraySetAsSeries(ha,true);
   ArraySetAsSeries(la,true);

   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_ZIGZAG); 
   PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
   PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_ZIGZAG); 
   PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_ZIGZAG); 
   PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
   PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_ZIGZAG); 
   PlotIndexSetInteger(6,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
   PlotIndexSetInteger(7,PLOT_DRAW_TYPE,DRAW_ZIGZAG); 
   PlotIndexSetInteger(8,PLOT_DRAW_TYPE,DRAW_ZIGZAG);
   PlotIndexSetInteger(9,PLOT_DRAW_TYPE,DRAW_ZIGZAG);

   PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(1,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(2,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(3,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(4,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(5,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(6,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(7,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(8,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(9,PLOT_LINE_STYLE,STYLE_SOLID);

   PlotIndexSetInteger(0,PLOT_LINE_COLOR, clrDarkOrange);
   PlotIndexSetInteger(1,PLOT_LINE_COLOR, clrRoyalBlue);
   PlotIndexSetInteger(2,PLOT_LINE_COLOR, clrForestGreen);
   PlotIndexSetInteger(3,PLOT_LINE_COLOR, clrSienna);
   PlotIndexSetInteger(4,PLOT_LINE_COLOR, clrDodgerBlue);
   PlotIndexSetInteger(5,PLOT_LINE_COLOR, clrGreen);
   PlotIndexSetInteger(6,PLOT_LINE_COLOR, clrBrown);
   PlotIndexSetInteger(7,PLOT_LINE_COLOR, clrMediumBlue);
   PlotIndexSetInteger(8,PLOT_LINE_COLOR, clrTeal);
   PlotIndexSetInteger(9,PLOT_LINE_COLOR, clrMaroon);

   PlotIndexSetInteger(0,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(1,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(2,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(3,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(4,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(5,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(6,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(7,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(8,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(9,PLOT_LINE_WIDTH, 0);

   SetIndexBuffer(20,nen_ZigZagH,INDICATOR_DATA);   // Plot = 10
   SetIndexBuffer(21,nen_ZigZagL,INDICATOR_DATA);   // Plot = 11
   PlotIndexSetInteger(10,PLOT_DRAW_TYPE,DRAW_ARROW); 
   PlotIndexSetInteger(10, PLOT_ARROW, 159); 
   PlotIndexSetInteger(10,PLOT_LINE_STYLE, STYLE_SOLID);
   PlotIndexSetInteger(10,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(10,PLOT_LINE_COLOR, clrMagenta);
   PlotIndexSetInteger(11,PLOT_DRAW_TYPE,DRAW_ARROW); 
   PlotIndexSetInteger(11, PLOT_ARROW, 159); 
   PlotIndexSetInteger(11,PLOT_LINE_STYLE, STYLE_SOLID);
   PlotIndexSetInteger(11,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(11,PLOT_LINE_COLOR, clrMagenta);

   SetIndexBuffer(22,ham,INDICATOR_DATA);   // Plot = 12
   SetIndexBuffer(23,lam,INDICATOR_DATA);   // Plot = 13
   PlotIndexSetInteger(12,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(12,PLOT_LINE_STYLE, STYLE_DOT);
   PlotIndexSetInteger(12,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(12,PLOT_LINE_COLOR, clrGreen);
   PlotIndexSetInteger(13,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(13,PLOT_LINE_STYLE, STYLE_DOT);
   PlotIndexSetInteger(13,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(13,PLOT_LINE_COLOR, clrOrange);

   SetIndexBuffer(24,ha,INDICATOR_DATA);   // Plot = 14
   SetIndexBuffer(25,la,INDICATOR_DATA);   // Plot = 15
   PlotIndexSetInteger(14,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(14,PLOT_LINE_STYLE, STYLE_DOT);
   PlotIndexSetInteger(14,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(14,PLOT_LINE_COLOR, clrGreen);
   PlotIndexSetInteger(15,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(15,PLOT_LINE_STYLE, STYLE_DOT);
   PlotIndexSetInteger(15,PLOT_LINE_WIDTH, 0);
   PlotIndexSetInteger(15,PLOT_LINE_COLOR, clrRed);

   SetIndexBuffer(26,ZigzagBuffer,INDICATOR_DATA);
   SetIndexBuffer(27,HighMapBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(28,LowMapBuffer,INDICATOR_CALCULATIONS);
   PlotIndexSetInteger(16,PLOT_DRAW_TYPE,DRAW_SECTION); 
   PlotIndexSetInteger(16,PLOT_LINE_STYLE, STYLE_SOLID);
   PlotIndexSetInteger(16,PLOT_LINE_WIDTH, 1);
   PlotIndexSetInteger(16,PLOT_LINE_COLOR, clrRed);

//--- set short name and digits   
   PlotIndexSetString(16,PLOT_LABEL,"ZigZag("+(string)ExtDepth+","+(string)ExtDeviation+","+(string)ExtBackstep+")");
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- set empty value
   PlotIndexSetDouble(16,PLOT_EMPTY_VALUE,0.0);
//--- to use in cycle
   deviation=ExtDeviation*_Point;
//---
   return(0);
  }
//+------------------------------------------------------------------+
//|  searching index of the highest bar                              |
//+------------------------------------------------------------------+
int iHighest(const double &array[],
             int depth,
             int startPos)
  {
   int index=startPos;
//--- start index validation
   if(startPos<0)
     {
      Print("Invalid parameter in the function iHighest, startPos =",startPos);
      return 0;
     }
   int size=ArraySize(array);
//--- depth correction if need
   if(startPos-depth<0) depth=startPos;
   double max=array[startPos];
//--- start searching
   for(int i=startPos;i>startPos-depth;i--)
     {
      if(array[i]>max)
        {
         index=i;
         max=array[i];
        }
     }
//--- return index of the highest bar
   return(index);
  }
//+------------------------------------------------------------------+
//|  searching index of the lowest bar                               |
//+------------------------------------------------------------------+
int iLowest(const double &array[],
            int depth,
            int startPos)
  {
   int index=startPos;
//--- start index validation
   if(startPos<0)
     {
      Print("Invalid parameter in the function iLowest, startPos =",startPos);
      return 0;
     }
   int size=ArraySize(array);
//--- depth correction if need
   if(startPos-depth<0) depth=startPos;
   double min=array[startPos];
//--- start searching
   for(int i=startPos;i>startPos-depth;i--)
     {
      if(array[i]<min)
        {
         index=i;
         min=array[i];
        }
     }
//--- return index of the lowest bar
   return(index);
  }
//+------------------------------------------------------------------+
//| 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 i=0;
   int limit=0,counterZ=0,whatlookfor=0;
   int shift=0,back=0,lasthighpos=0,lastlowpos=0;
   double val=0,res=0;
   double curlow=0,curhigh=0,lasthigh=0,lastlow=0;
//--- auxiliary enumeration
   enum looling_for
     {
      Pike=1,  // searching for next high
      Sill=-1  // searching for next low
     };
//--- initializing
   if(prev_calculated==0)
     {
      ArrayInitialize(ZigzagBuffer,0.0);
      ArrayInitialize(HighMapBuffer,0.0);
      ArrayInitialize(LowMapBuffer,0.0);
     }
//--- 
   if(rates_total<100) return(0);
//--- set start position for calculations
   if(prev_calculated==0) limit=ExtDepth;

//--- ZigZag was already counted before
   if(prev_calculated>0)
     {
      i=rates_total-1;
      //--- searching third extremum from the last uncompleted bar
      while(counterZ<level && i>rates_total-100)
        {
         res=ZigzagBuffer[i];
         if(res!=0) counterZ++;
         i--;
        }
      i++;
      limit=i;

      //--- what type of exremum we are going to find
      if(LowMapBuffer[i]!=0)
        {
         curlow=LowMapBuffer[i];
         whatlookfor=Pike;
        }
      else
        {
         curhigh=HighMapBuffer[i];
         whatlookfor=Sill;
        }
      //--- chipping
      for(i=limit+1;i<rates_total && !IsStopped();i++)
        {
         ZigzagBuffer[i]=0.0;
         LowMapBuffer[i]=0.0;
         HighMapBuffer[i]=0.0;
        }
     }

//--- searching High and Low
   for(shift=limit;shift<rates_total && !IsStopped();shift++)
     {
      val=low[iLowest(low,ExtDepth,shift)];
      if(val==lastlow) val=0.0;
      else
        {
         lastlow=val;
         if((low[shift]-val)>deviation) val=0.0;
         else
           {
            for(back=1;back<=ExtBackstep;back++)
              {
               res=LowMapBuffer[shift-back];
               if((res!=0) && (res>val)) LowMapBuffer[shift-back]=0.0;
              }
           }
        }
      if(low[shift]==val) LowMapBuffer[shift]=val; else LowMapBuffer[shift]=0.0;
      //--- high
      val=high[iHighest(high,ExtDepth,shift)];
      if(val==lasthigh) val=0.0;
      else
        {
         lasthigh=val;
         if((val-high[shift])>deviation) val=0.0;
         else
           {
            for(back=1;back<=ExtBackstep;back++)
              {
               res=HighMapBuffer[shift-back];
               if((res!=0) && (res<val)) HighMapBuffer[shift-back]=0.0;
              }
           }
        }
      if(high[shift]==val) HighMapBuffer[shift]=val; else HighMapBuffer[shift]=0.0;
     }

//--- last preparation
   if(whatlookfor==0)// uncertain quantity
     {
      lastlow=0;
      lasthigh=0;
     }
   else
     {
      lastlow=curlow;
      lasthigh=curhigh;
     }

//--- final rejection
   for(shift=limit;shift<rates_total && !IsStopped();shift++)
     {
      res=0.0;
      switch(whatlookfor)
        {
         case 0: // search for peak or lawn
            if(lastlow==0 && lasthigh==0)
              {
               if(HighMapBuffer[shift]!=0)
                 {
                  lasthigh=high[shift];
                  lasthighpos=shift;
                  whatlookfor=Sill;
                  ZigzagBuffer[shift]=lasthigh;
                  res=1;
                 }
               if(LowMapBuffer[shift]!=0)
                 {
                  lastlow=low[shift];
                  lastlowpos=shift;
                  whatlookfor=Pike;
                  ZigzagBuffer[shift]=lastlow;
                  res=1;
                 }
              }
            break;
         case Pike: // search for peak
            if(LowMapBuffer[shift]!=0.0 && LowMapBuffer[shift]<lastlow && HighMapBuffer[shift]==0.0)
              {
               ZigzagBuffer[lastlowpos]=0.0;
               lastlowpos=shift;
               lastlow=LowMapBuffer[shift];
               ZigzagBuffer[shift]=lastlow;
               res=1;
              }
            if(HighMapBuffer[shift]!=0.0 && LowMapBuffer[shift]==0.0)
              {
               lasthigh=HighMapBuffer[shift];
               lasthighpos=shift;
               ZigzagBuffer[shift]=lasthigh;
               whatlookfor=Sill;
               res=1;
              }
            break;
         case Sill: // search for lawn
            if(HighMapBuffer[shift]!=0.0 && HighMapBuffer[shift]>lasthigh && LowMapBuffer[shift]==0.0)
              {
               ZigzagBuffer[lasthighpos]=0.0;
               lasthighpos=shift;
               lasthigh=HighMapBuffer[shift];
               ZigzagBuffer[shift]=lasthigh;
              }
            if(LowMapBuffer[shift]!=0.0 && HighMapBuffer[shift]==0.0)
              {
               lastlow=LowMapBuffer[shift];
               lastlowpos=shift;
               ZigzagBuffer[shift]=lastlow;
               whatlookfor=Pike;
              }
            break;
         default: return(rates_total);
        }
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Por favor, ayude a los desarrolladores de terminales a arreglar este error.

Imagen con artefactos:


Запуск платформы - Для продвинутых пользователей - MetaTrader 5
Запуск платформы - Для продвинутых пользователей - MetaTrader 5
  • www.metatrader5.com
По завершении установки в меню "Пуск" создается группа программ торговой платформы, а на рабочем столе дополнительно помещается ярлык программы. Используйте их для запуска. Нельзя запускать одновременно две копии платформы из одной директории. Чтобы одновременно запустить несколько копий, установите соответствующее количество программ в разные...
Archivos adjuntos:
ZigZag_test.mq5  17 kb
 
Eugeni Neumoin:

No puedo superar el error.

Tomé el zigzag de la entrega de Metatrader para demostrar el error. Se han añadido búferes adicionales al código, tomados de mi programa. En este código no se realizan manipulaciones con búferes adicionales. Son sólo para demostrar el error.

Trazado de este zigzag en el marco de tiempo EURUSD H1. Cerró la terminal. Se han eliminado del historial todas las series temporales generadas para el EURUSD. Es decir, borró todos los archivos *.hcc y *.hc del par de divisas EURUSD. Se ha hecho para garantizar la carga de los archivos .hcc y la generación de los archivos .hc a partir de una hoja limpia.

Después de iniciar el terminal, verá un montón de artefactos en el gráfico del EURUSD. Estos artefactos no pueden ser tratados.

Adjunto el código modificado del zigzag en forma de texto y en forma de archivo.

Quiero advertir que los parámetros del zigzag se especifican a través de #propert.

Todos los demás búferes no se establecen a través de #propert, porque todo, incluyendo los búferes de zigzag, se cambian dinámicamente.

Por favor, ayude a los desarrolladores de terminales a arreglar este error.

Imagen con artefactos:


Es necesario inicializar todos los búferes.

Si no hay ningún valor en el buffer de la barra, debe escribirse explícitamente en el buffer. En otras palabras, si el valor calculado debe salir al búfer, escríbalo en el búfer, de lo contrario escriba un valor vacío.

 
Vict:

En general, no me lo esperaba:

Las pruebas por mi cuenta no han mostrado ninguna diferencia notable.


Si en lugar de

hacer

   Data data[];
   
   ArrayResize(data, 32768);


¡Hay una ralentización de 6x!

 
Artyom Trishkin:

Es necesario inicializar todos los búferes.

Si no hay ningún valor en el buffer de la barra, debe escribirse explícitamente en el buffer. Es decir, si el valor calculado debe salir al buffer - lo escribimos en el buffer, de lo contrario - escribimos un valor vacío.

Lo siento, se me pasó la inicialización. Lo tengo en mi programa pero se me pasó en el ejemplo.

Se adjunta un archivo con la inicialización. El efecto es el mismo.

La pregunta para los desarrolladores sigue siendo. Por favor, arregle este error.

-------------

En mi opinión, ocurre lo siguiente. Al lanzar el programa junto con el terminal, el tamaño de las series de tiempo es igual a cero o tiene algún valor mínimo.

El programa se inicializa en el trozo de historia existente. Pero cuando se aumenta el tamaño de las series de tiempo, los fragmentos de memoria que no pasaron por la inicialización se están utilizando para las matrices de búfer. Como resultado, tenemos este efecto.

Intenté manejar este efecto usando eventos de la terminal. No obstante, los artefactos aparecen durante una fracción de segundo. Y esto no es bueno. Dicho programa no debe ser liberado.

He aquí cómo solucionarlo. Después de la asignación de memoria para los búferes, debe borrar esta memoria de inmediato. Pero, ¿cómo podemos hacerlo? No he encontrado esa característica en el lado del desarrollador de la aplicación del terminal.

Archivos adjuntos:
ZigZag_test.mq5  17 kb