Errori, bug, domande - pagina 2504

 
Francuz:
Gente, condividete qualche informazione. Per cosa usi l'allineamento?

questa è una programmazione orientata al procione!

Ahimè, non puoi farne a meno ;)

 
Igor Makanu:

questa è una programmazione orientata al procione!

Ahimè, non puoi farne a meno ;)

Ne sono consapevole. Non ti sto chiedendo di insegnarmi l'OOP. Ho chiesto chi usa l'allineamento per quale scopo.

 
Francuz:
Gente, potete condividere qualche informazione? Per cosa usi l'allineamento?

Tutto ciò è molto utile in un ambiente multi-thread, io lo vedo così. Cosa c'entra MKL? Non lo so, la domanda è stata posta, quindi mi sono bloccato.

E in generale - queste sono le basi, una comprensione di base è necessaria per ogni programmatore decente.

ZS: Beh, ci sono molti fanatici della velocità qui, se iniziano ad allineare tutto in modo intelligente, dovrebbero volare ancora più velocemente, almeno in teoria.
 
Francuz:
Gente, condividete qualche informazione. Per cosa usi l'allineamento?
Può essere necessario quando si trasferiscono strutture a librerie esterne.
 

Vict:

ZS: beh ci sono un sacco di fan della velocità qui, se iniziano a farlo bene, dovrebbe andare ancora più veloce, in teoria almeno.


In generale, non me lo aspettavo nemmeno:

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

Il codice è un po' troppo complicato - ho provato a colpire quell'elemento che non entra nella linea di cache e sbatterci direttamente sopra, ma non è riuscito (probabilmente si potrebbe fare se volessi, ma mi sono annoiato), e non ho cambiato molto il codice. Ma questo è ancora più impressionante - solo uno dei 16 collassi è fatto su un elemento che non cade nella linea della cache, tuttavia dà un risultato sensato.

SZY: più oggettivamente in questo caso fare RIGHT_ALIGNED inserendo due brevi, invece di rimuovere unico (così otterremo due aggiornamenti di cache-line per entrambi i casi). L'accelerazione sarà più modesta, ma ancora circa 1,5 volte tanto.

 

A proposito, in mql il valore predefinito di pack è 1, più o meno.

A giudicare dal post precedente, forse ha senso prescrivere 8 esplicitamente a tutte le strutture e classi.

 

Non riesco a superare l'errore.

Ho preso lo zigzag dalla consegna di Metatrader per dimostrare l'errore. Aggiunti buffer aggiuntivi al codice, presi dal mio programma. Nessuna manipolazione con buffer aggiuntivi è prevista in questo codice. Sono solo per dimostrare l'errore.

Tracciato questo zigzag sul timeframe EURUSD H1. Chiuso il terminale. Cancellato tutte le serie temporali generate per EURUSD dalla cronologia. Cioè ho cancellato tutti i file *.hcc e *.hc della coppia di valute EURUSD. È stato fatto per assicurare il caricamento dei file .hcc e la generazione dei file .hc da un foglio pulito.

Dopo che il terminale è stato avviato, vedrai molti artefatti sul grafico EURUSD. Questi artefatti non possono essere trattati.

Allego il codice modificato dello zigzag sotto forma di testo e sotto forma di file.

Voglio avvertirvi che i parametri dello zigzag sono specificati tramite #propert.

Tutti gli altri buffer non sono impostati attraverso #propert, perché tutto, compresi i buffer degli zigzag, sono cambiati dinamicamente.

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

Si prega di aiutare gli sviluppatori del terminale a risolvere questo bug.

Immagine con artefatti:


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

Non riesco a superare l'errore.

Ho preso lo zigzag dalla consegna di Metatrader per dimostrare l'errore. Aggiunti buffer aggiuntivi al codice, presi dal mio programma. Nessuna manipolazione con buffer aggiuntivi è prevista in questo codice. Sono solo per dimostrare l'errore.

Tracciato questo zigzag sul timeframe EURUSD H1. Chiuso il terminale. Cancellato tutte le serie temporali generate per EURUSD dalla cronologia. Cioè ho cancellato tutti i file *.hcc e *.hc della coppia di valute EURUSD. È stato fatto per assicurare il caricamento dei file .hcc e la generazione dei file .hc da un foglio pulito.

Dopo che il terminale è stato avviato, vedrai molti artefatti sul grafico EURUSD. Questi artefatti non possono essere trattati.

Allego il codice modificato dello zigzag sotto forma di testo e sotto forma di file.

Voglio avvertirvi che i parametri dello zigzag sono specificati tramite #propert.

Tutti gli altri buffer non sono impostati tramite #propert, perché tutto, compresi i buffer degli zigzag, sono cambiati dinamicamente.

Si prega di aiutare gli sviluppatori del terminale a risolvere questo bug.

Immagine con artefatti:


Tutti i buffer devono essere inizializzati.

Se non c'è un valore nel buffer sulla barra, deve essere scritto esplicitamente nel buffer. In altre parole, se il valore calcolato deve essere emesso nel buffer, scrivilo nel buffer, altrimenti scrivi un valore vuoto.

 
Vict:

In generale, non me lo aspettavo nemmeno:

Le corse per conto mio non hanno mostrato alcuna differenza evidente.


Se invece di

fare

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


C'è un rallentamento di 6 volte!

 
Artyom Trishkin:

Tutti i buffer devono essere inizializzati.

Se non c'è un valore nel buffer sulla barra, deve essere scritto esplicitamente nel buffer. Cioè, se il valore calcolato deve essere emesso nel buffer - lo scriviamo nel buffer, altrimenti - scriviamo un valore vuoto.

Scusa, mi sono perso l'inizializzazione. Ce l'ho nel mio programma ma l'ho perso nell'esempio.

In allegato c'è un file con l'inizializzazione. L'effetto è lo stesso.

La domanda per gli sviluppatori rimane. Per favore, correggete questo bug.

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

Secondo me, succede quanto segue. Quando si lancia il programma insieme al terminale, la dimensione della serie temporale è uguale a zero o ha qualche valore minimo.

Il programma viene inizializzato sul pezzo di storia esistente. Ma quando la dimensione delle serie temporali viene aumentata, i frammenti di memoria che non sono passati attraverso l'inizializzazione vengono utilizzati per gli array di buffer. Di conseguenza, abbiamo questo effetto.

Ho provato a gestire questo effetto usando gli eventi del terminale. Tuttavia, gli artefatti appaiono per una frazione di secondo. E questo non è buono. Un tale programma non deve essere rilasciato.

Ecco come risolvere il problema. Dopo l'allocazione della memoria per i buffer, dovreste cancellare subito questa memoria. Ma come possiamo farlo? Non ho trovato questa caratteristica dal lato dello sviluppatore dell'applicazione terminale.

File:
ZigZag_test.mq5  17 kb