Erreurs, bugs, questions - page 2504

 
Igor Makanu:

c'est une programmation orientée raton laveur!

Hélas, on ne peut pas s'en passer ;)

J'en suis conscient. Je ne vous demande pas de m'apprendre la programmation opérationnelle. J'ai demandé qui utilise l'alignement dans quel but.

 
Francuz:
Les gens, pouvez-vous partager quelques informations ? Pourquoi utilisez-vous l'alignement ?

Tout cela est très utile dans un environnement multithread, c'est ainsi que je le vois. Qu'est-ce que MKL a à voir là-dedans ? Je ne sais pas, la question a été posée, alors je suis resté bloqué.

Et en général - ce sont les bases, une compréhension de base est nécessaire pour tout bon programmeur.

ZS : Eh bien, il y a beaucoup de fanatiques de la vitesse ici, s'ils commencent à tout aligner intelligemment, ils devraient voler encore plus vite, en théorie du moins.
 
Francuz:
Les gens, partagez quelques informations. Pourquoi utilisez-vous l'alignement ?
Cela peut être nécessaire lors du transfert de structures vers des bibliothèques externes.
 

Vict:

ZS : Eh bien, il y a beaucoup de fans de vitesse ici, s'ils commencent à bien faire les choses, ça devrait aller encore plus vite, en théorie du moins.


En général, je ne m'y attendais même pas :

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

Le code est un peu trop compliqué - j'ai essayé de frapper l'élément qui ne rentre pas dans la ligne de cache et de taper directement dessus, mais ça n'a pas marché (ça pourrait probablement être fait si je le voulais, mais je me suis ennuyé), et je n'ai pas beaucoup changé le code. Mais ceci est encore plus impressionnant - seulement un des 16 effondrements est fait sur un élément qui ne tombe pas dans la ligne de cache, néanmoins il donne un résultat raisonnable.

SZY : il est plus objectif dans ce cas de faire RIGHT_ALIGNED en insérant deux courts, au lieu de supprimer l'unique (ainsi nous réaliserons deux mises à jour de la ligne de cache pour les deux cas). L'accélération sera plus modeste, mais toujours environ 1,5 fois plus importante.

 

Au fait, dans mql, la valeur par défaut de pack est 1, en quelque sorte.

A en juger par le post précédent, il est peut-être judicieux de prescrire explicitement 8 à toutes les structures et classes.

 

Je n'arrive pas à me remettre de l'erreur.

J'ai pris le zigzag de la livraison Metatrader pour démontrer l'erreur. Ajout de tampons supplémentaires au code, pris dans mon programme. Aucune manipulation avec des tampons supplémentaires n'est prévue dans ce code. Ils servent juste à démontrer l'erreur.

J'ai tracé ce zigzag sur la trame temporelle H1 de l'EURUSD. Fermez le terminal. Suppression de toutes les séries chronologiques générées pour EURUSD dans l'historique. J'ai donc supprimé tous les fichiers *.hcc et *.hc de la paire de devises EURUSD. Cela a été fait pour assurer le chargement des fichiers .hcc et la génération des fichiers .hc à partir d'une feuille propre.

Après le démarrage du terminal, vous verrez beaucoup d'artefacts sur le graphique EURUSD. Ces artefacts ne peuvent pas être traités.

Je joins le code modifié du zigzag sous forme de texte et sous forme de fichier.

Je tiens à vous avertir que les paramètres du zigzag sont spécifiés via #propert.

Tous les autres tampons ne sont pas définis via #propert, car tout, y compris les tampons de zigzags, est modifié dynamiquement.

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

Veuillez aider les développeurs du terminal à corriger ce bogue.

Photo avec artefacts :


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

Je n'arrive pas à me remettre de cette erreur.

J'ai pris le zigzag de la livraison Metatrader pour démontrer l'erreur. Ajout de tampons supplémentaires au code, pris dans mon programme. Aucune manipulation avec des tampons supplémentaires n'est prévue dans ce code. Ils servent juste à démontrer l'erreur.

J'ai tracé ce zigzag sur la trame temporelle H1 de l'EURUSD. Fermez le terminal. Suppression de toutes les séries chronologiques générées pour EURUSD dans l'historique. J'ai donc supprimé tous les fichiers *.hcc et *.hc de la paire de devises EURUSD. Cela a été fait pour assurer le chargement des fichiers .hcc et la génération des fichiers .hc à partir d'une feuille propre.

Après le démarrage du terminal, vous verrez beaucoup d'artefacts sur le graphique EURUSD. Ces artefacts ne peuvent pas être traités.

Je joins le code modifié du zigzag sous forme de texte et sous forme de fichier.

Je tiens à vous avertir que les paramètres du zigzag sont spécifiés via #propert.

Tous les autres tampons ne sont pas définis via #propert, car tout, y compris les tampons de zigzags, est modifié dynamiquement.

Veuillez aider les développeurs du terminal à corriger ce bogue.

Photo avec artefacts :


Tous les tampons doivent être initialisés.

S'il n'y a pas de valeur dans le tampon sur la barre, elle doit être écrite explicitement dans le tampon. En d'autres termes, si la valeur calculée doit être sortie dans le tampon, écrivez-la dans le tampon, sinon écrivez une valeur vide.

 
Vict:

En général, je ne m'attendais même pas à ça :

Les essais effectués par mes soins n'ont montré aucune différence notable.


Si au lieu de

faire

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


Il y a un ralentissement de 6x !

 
Artyom Trishkin:

Tous les tampons doivent être initialisés.

S'il n'y a pas de valeur dans le tampon sur la barre, elle doit être explicitement écrite dans le tampon. C'est-à-dire, si la valeur calculée doit être sortie dans le tampon - nous l'écrivons dans le tampon, sinon - nous écrivons une valeur vide.

Désolé, j'ai raté l'initialisation. Je l'ai dans mon programme mais je l'ai manqué dans l'exemple.

Vous trouverez ci-joint un fichier avec l'initialisation. L'effet est le même.

La question qui se pose aux développeurs demeure. Veuillez corriger ce bogue.

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

À mon avis, il se passe ce qui suit. Lorsque l'on lance le programme avec le terminal, la taille de la série temporelle est égale à zéro ou a une valeur minimale.

Le programme est initialisé sur le morceau d'histoire existant. Mais lorsque la taille des séries temporelles est augmentée, les fragments de mémoire qui n'ont pas passé l'initialisation sont utilisés pour les tableaux tampons. Par conséquent, nous avons cet effet.

J'ai essayé de gérer cet effet en utilisant les événements du terminal. Les artefacts apparaissent tout de même pendant une fraction de seconde. Et ce n'est pas bon. Un tel programme ne doit pas être publié.

Voici comment le réparer. Après l'allocation de mémoire pour les tampons, vous devez effacer cette mémoire immédiatement. Mais comment pouvons-nous le faire ? Je n'ai pas trouvé une telle fonctionnalité du côté du développeur de l'application du terminal.

Dossiers :
ZigZag_test.mq5  17 kb
 

un bug de longue date dans l'éditeur :

- enregistrer le fichier sous un nouveau nom (par exemple : nom_v1.2)
- placer le curseur sur une variable (ou un appel de fonction)
- appuyez sur alt+g

- un ancien fichier est ouvert et l'édition saute à celui-ci (