Erros, bugs, perguntas - página 2504

 
Francuz:
Pessoas, partilhem alguma informação. Para que é que está a usar o alinhamento?

esta é uma programação orientada para o Raccoon!

Infelizmente, não se pode passar sem ele ;)

 
Igor Makanu:

esta é uma programação orientada para o Raccoon!

Infelizmente, não se pode passar sem ele ;)

Estou ciente disso. Não lhe peço que me ensine sobre o OOP. Perguntei quem usa o alinhamento para que fins.

 
Francuz:
Pessoal, podem partilhar alguma informação? Para que é que está a usar o alinhamento?

Tudo isto vem muito a calhar num ambiente multi-tarefas, eu vejo-o dessa forma. O que é que a MKL tem a ver com isto? Não sei, a pergunta foi feita, por isso fiquei preso.

E em geral - estas são as bases, um entendimento básico é necessário para qualquer programador decente.

ZS: Bem, há aqui muitos fanáticos da velocidade, se eles começarem a alinhar tudo inteligentemente, devem voar ainda mais rápido, pelo menos em teoria.
 
Francuz:
Pessoas, partilhem alguma informação. Para que é que está a usar o alinhamento?
Poderá ser necessário aquando da transferência de estruturas para bibliotecas externas.
 

Vict:

ZS: bem, há aqui muitos fãs da velocidade, se eles começarem a acertar, deve ir ainda mais rápido, pelo menos em teoria.


Em geral, eu nem sequer esperava isso:

#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
*/

O código é um pouco complicado demais - tentei acertar naquele elemento que não cabe na linha de cache e bater directamente nele, mas falhou (provavelmente poderia ser feito se quisesse, mas aborreci-me), e não mudei muito o código. Mas isto é ainda mais impressionante - apenas um dos 16 colapsos é feito sobre um elemento que não cai na linha de cache, no entanto, dá um resultado sensato.

SZY: mais objectivamente, neste caso, fazer RIGHT_ALIGNED inserindo dois curtos, em vez de remover o único (por isso, vamos conseguir duas actualizações da linha de cache para ambos os casos). A velocidade será mais modesta, mas ainda assim cerca de 1,5 vezes mais.

 

A propósito, em mql o valor por defeito do pacote é 1, mais ou menos.

A julgar pelo post anterior, talvez faça sentido prescrever 8 explicitamente a todas as estruturas e classes.

 

Não consigo ultrapassar o erro.

Tirei o ziguezague da entrega do Metatrader para demonstrar o erro. Adicionei buffers adicionais ao código, retirados do meu programa. Nenhuma manipulação com amortecedores adicionais está prevista neste código. São apenas para demonstrar o erro.

Plotou este ziguezague sobre o calendário EURUSD H1. Fechou o terminal. Eliminadas da história todas as séries cronológicas geradas para o EURUSD. Isto é, eliminou todos os ficheiros *.hcc e *.hc do par de moedas EURUSD. Tem sido feito para assegurar o carregamento de ficheiros .hcc e a geração de ficheiros .hc a partir de uma folha limpa.

Depois de o terminal ter sido iniciado, verá muitos artefactos no gráfico EURUSD. Estes artefactos não podem ser tratados.

Estou a anexar o código modificado do ziguezague sob a forma de texto e sob a forma de ficheiro.

Quero advertir-vos que os parâmetros do ziguezague são especificados através de #propert.

Todos os outros amortecedores não são definidos via #propert, porque tudo, incluindo os amortecedores em ziguezague, são mudados de forma dinâmica.

//+------------------------------------------------------------------+
//|                                                       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, ajude os criadores de terminais a corrigir este erro.

Fotografia com artefactos:


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

Não consigo ultrapassar o erro.

Tirei o ziguezague da entrega do Metatrader para demonstrar o erro. Adicionei buffers adicionais ao código, retirados do meu programa. Não estão previstas neste código manipulações com amortecedores adicionais. São apenas para demonstrar o erro.

Plotou este ziguezague sobre o calendário EURUSD H1. Fechou o terminal. Eliminadas da história todas as séries cronológicas geradas para o EURUSD. Isto é, eliminou todos os ficheiros *.hcc e *.hc do par de moedas EURUSD. Tem sido feito para assegurar o carregamento de ficheiros .hcc e a geração de ficheiros .hc a partir de uma folha limpa.

Depois de o terminal ter sido iniciado, verá muitos artefactos no gráfico EURUSD. Estes artefactos não podem ser tratados.

Estou a anexar o código modificado do ziguezague sob a forma de texto e sob a forma de ficheiro.

Quero advertir-vos que os parâmetros do ziguezague são especificados através de #propert.

Todos os outros amortecedores não são definidos através de #propert, porque tudo, incluindo os amortecedores em ziguezague, são mudados de forma dinâmica.

Por favor, ajude os criadores de terminais a corrigir este erro.

Fotografia com artefactos:


Todos os amortecedores precisam de ser inicializados.

Se não houver valor no tampão na barra, este deve ser escrito explicitamente no tampão. Por outras palavras, se o valor calculado tiver de ser produzido para o buffer, escreva-o para o buffer, caso contrário escreva um valor vazio.

 
Vict:

Em geral, eu nem sequer estava à espera disto:

As corridas por conta própria não mostraram qualquer diferença perceptível.


Se em vez de

fazer

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


Há um abrandamento de 6x!

 
Artyom Trishkin:

Todos os amortecedores precisam de ser inicializados.

Se não houver nenhum valor no tampão na barra, este deve ser explicitamente escrito no tampão. Isto é, se o valor calculado deve ser produzido em buffer - escrevemo-lo em buffer, caso contrário - escrevemos valor vazio.

Desculpe, perdi a inicialização. Tenho-o no meu programa mas perdi-o no exemplo.

Em anexo encontra-se um ficheiro com a inicialização. O efeito é o mesmo.

A questão para os criadores permanece. Por favor, corrija este erro.

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

Na minha opinião, acontece o seguinte. Ao lançar o programa juntamente com o terminal, o tamanho da série temporal ou é igual a zero ou tem um valor mínimo.

O programa é inicializado na peça de história existente. Mas quando o tamanho das séries temporais é aumentado, fragmentos de memória que não passaram pela inicialização estão a ser utilizados para matrizes tampão. Como resultado, temos este efeito.

Tentei lidar com este efeito utilizando eventos do terminal. Mesmo assim, os artefactos aparecem durante uma fracção de segundo. E isto não é bom. Tal programa não deve ser lançado.

Aqui está como consertá-lo. Após a alocação de memória para buffers, deve limpar imediatamente esta memória. Mas como o podemos fazer? Ainda não encontrei tal característica do lado do desenvolvedor da aplicação terminal.

Arquivos anexados:
ZigZag_test.mq5  17 kb
Razão: