Errores, fallos, preguntas - página 1986

 
Alexey Kozitsyn:

Hay una inicialización en OnCalculate() en la primera ejecución (prev_calculated == 0). ¿Crees que moverlo a OnInit() cambiará algo? Bueno, lo intentaré, por supuesto, pero esto es algo fuera del reino de la fantasía...

Corta. Como he dicho, en OnDeinit() se inicializan arrays, que dejan de utilizarse en el siguiente arranque (cambiando los parámetros de entrada). Si esto (inicializar un array que no se usa como buffer) ayuda - también sería un bug de MT. Resultaría que no sólo no se utilizan las matrices, sino que éstas (no asignadas) podrían seguir siendo inicializadas y afectaría al mapeo...

Sin código es difícil. Avísanos de lo que dice el servicio de atención al cliente después.
 
Anatoli Kazharski:
Es difícil sin el código. Avísame lo que dice el servicio técnico después.
Lo haré.
 
Anatoli Kazharski:
Es difícil sin código. Avísame aquí más tarde lo que dice el servicio técnico.

Aquí está el código de prueba, si te interesa.

Inicialmente, el parámetro indicador es falso.

Ponemos el indicador en el gráfico. Traza un histograma.

Establecemos los parámetros como verdaderos.

Dibuja el histograma y las flechas.

Haz que el parámetro sea falso. En la TF actual desaparecen las flechas (no siempre). Si cambiamos a diferentes TFs, las flechas aparecen de forma caótica en algunos de ellos a pesar de que los buffers se limpian al desinicializarse.

#property indicator_separate_window
#property indicator_plots 3
#property indicator_buffers 4
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
input bool inpUseArrows=false;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double bufGisto[];
double bufGistoColor[];
double bufArrowUp[];
double bufArrowDn[];
//---
const double EMPTY=EMPTY_VALUE;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Размечаем массив цветов
   color colors[2];
   colors[ 0 ]= clrLime;
   colors[ 1 ] = clrRed;
//--- Устанавливаем параметры графических серий
   SetPlotParametersColorHistogram(0,0,bufGisto,bufGistoColor,false,"test gisto",colors,EMPTY,2);
//--- Проверяем, нужно ли отображать объемы
   if(inpUseArrows) // Если отображать нужно
     {
      SetPlotParametersArrow(1,2,bufArrowUp,false,"test up",EMPTY,clrLime,233,10);
      SetPlotParametersArrow(2,3,bufArrowDn,false,"test dn",EMPTY,clrRed,234,-10);
     }
//---
   IndicatorSetInteger(INDICATOR_DIGITS,0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(inpUseArrows)
     {
      ArrayInitialize(bufArrowUp,EMPTY);
      ArrayInitialize(bufArrowDn,EMPTY);
     }
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   if(prev_calculated==0)
     {
      ArrayInitialize(bufGisto,EMPTY);
      //---
      if(inpUseArrows)
        {
         ArrayInitialize(bufArrowUp,EMPTY);
         ArrayInitialize(bufArrowDn,EMPTY);
        }
      //---
      for(int i=0; i<rates_total; i++)
        {
         bufGisto[i]=(open[i]-close[i])/_Point;
         bufGistoColor[i]=(bufGisto[i]<0) ? 1 : 0;
         //---
         if(inpUseArrows)
           {
            if(bufGisto[i]>20)
               bufArrowDn[i]=bufGisto[i];
            else if(bufGisto[i]<-20)
               bufArrowUp[i]=bufGisto[i];
           }
        }
     }
   else if(rates_total>prev_calculated)
     {
      bufGisto[rates_total-1]=EMPTY;
      //---
      if(inpUseArrows)
        {
         bufArrowUp[ rates_total-1 ] = EMPTY;
         bufArrowDn[ rates_total-1 ] = EMPTY;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Параметры графического построения: цветная гист-а от 0 линии                |
//+------------------------------------------------------------------+
void SetPlotParametersColorHistogram(const int plotIndex,// Индекс графической серии
                                     const int bufferNum,// Номер первого буфера серии
                                     double& value[],                              // Буфер значений
                                     double& clr[],                                 // Буфер цветов
                                     const bool asSeries,                           // Флаг нумерации как в таймсерии
                                     const string label,                           // Имя серии
                                     const color& colors[],                        // Цвета линии
                                     const double emptyValue = EMPTY_VALUE,         // Пустые значения серии
                                     const int width = 0,                           // Толщина линии
                                     const ENUM_LINE_STYLE style = STYLE_SOLID,      // Стиль линии
                                     const int drawBegin = 0,                        // Количество баров без отрисовки
                                     const int shift=0                           // Сдвиг построения в барах
                                     )
  {
//--- Привязываем буферы
   SetIndexBuffer(bufferNum,value,INDICATOR_DATA);
   SetIndexBuffer(bufferNum+1,clr,INDICATOR_COLOR_INDEX);
//--- Устанавливаем порядок нумерации в массивах-буферах
   ArraySetAsSeries(value,asSeries);
   ArraySetAsSeries(clr,asSeries);
//--- Устанавливаем тип графического построения
   PlotIndexSetInteger(plotIndex,PLOT_DRAW_TYPE,DRAW_COLOR_HISTOGRAM);
//--- Устанавливаем имя графической серии
   PlotIndexSetString(plotIndex,PLOT_LABEL,label);
//--- Устанавливаем пустые значения в буферах
   PlotIndexSetDouble(plotIndex,PLOT_EMPTY_VALUE,emptyValue);
//--- Устанавливаем количество цветов индикатора
   const int size=ArraySize(colors);
   PlotIndexSetInteger(plotIndex,PLOT_COLOR_INDEXES,size);
//--- Устанавливаем цвета индикатора
   for(int i=0; i<size; i++)
      PlotIndexSetInteger(plotIndex,PLOT_LINE_COLOR,i,colors[i]);
//--- Устанавливаем толщину линии
   PlotIndexSetInteger(plotIndex,PLOT_LINE_WIDTH,width);
//--- Устанавливаем стиль линии
   PlotIndexSetInteger(plotIndex,PLOT_LINE_STYLE,style);
//--- Устанавливаем количество баров без отрисовки и значений в DataWindow
   PlotIndexSetInteger(plotIndex,PLOT_DRAW_BEGIN,drawBegin);
//--- Устанавливаем сдвиг графического построения по оси времени в барах
   PlotIndexSetInteger(plotIndex,PLOT_SHIFT,shift);
  }
//+------------------------------------------------------------------+
//| Параметры графического построения: стрелки                                                          |
//+------------------------------------------------------------------+
void SetPlotParametersArrow(const int plotIndex,// Индекс графической серии
                            const int bufferNum,// Номер первого буфера серии
                            double &value[],// Буфер значений
                            const bool asSeries,// Флаг нумерации как в таймсерии
                            const string label,// Имя серии
                            const double emptyValue=EMPTY_VALUE,// Пустые значения серии
                            const color clr=clrRed,// Цвет стрелок
                            const int arrowCode= 159,// Код стрелок
                            const int arrowShift = 0,// Сдвиг стрелок по вертикали
                            const int width=0,// Толщина стрелок
                            const int drawBegin=0,// Количество баров без отрисовки
                            const int shift=0                     // Сдвиг построения в барах
                            )
  {
//--- Привязываем буферы
   SetIndexBuffer(bufferNum,value,INDICATOR_DATA);
//--- Устанавливаем порядок нумерации в массивах-буферах
   ArraySetAsSeries(value,asSeries);
//--- Устанавливаем тип графического построения
   PlotIndexSetInteger(plotIndex,PLOT_DRAW_TYPE,DRAW_ARROW);
//--- Устанавливаем имя графической серии
   PlotIndexSetString(plotIndex,PLOT_LABEL,label);
//--- Устанавливаем пустые значения в буферах
   PlotIndexSetDouble(plotIndex,PLOT_EMPTY_VALUE,emptyValue);
//--- Устанавливаем цвет индикатора
   PlotIndexSetInteger(plotIndex,PLOT_LINE_COLOR,0,clr);
//--- Устанавливаем код стрелок
   PlotIndexSetInteger(plotIndex,PLOT_ARROW,arrowCode);
//--- Устанавливаем смещение стрелок по вертикали
   PlotIndexSetInteger(plotIndex,PLOT_ARROW_SHIFT,arrowShift);
//--- Устанавливаем толщину стрелок
   PlotIndexSetInteger(plotIndex,PLOT_LINE_WIDTH,width);
//--- Устанавливаем количество баров без отрисовки и значений в DataWindow
   PlotIndexSetInteger(plotIndex,PLOT_DRAW_BEGIN,drawBegin);
//--- Устанавливаем сдвиг графического построения по оси времени в барах
   PlotIndexSetInteger(plotIndex,PLOT_SHIFT,shift);
  }
//+------------------------------------------------------------------+
 
Anatoli Kazharski:
No va a ninguna parte. Servicedesk #1832411x64, 1643.
 
Alexey Kozitsyn:
No va en ningún sentido. Servicio de atención al cliente #1832411x64, 1643.

Independientemente de que se especifiquen matrices para las flechas como búferes, éstas siguen siendo rígidas:

#property indicator_plots   3
#property indicator_buffers 4

//---

Alternativamente, si las flechas no necesitan ser mostradas, pueden simplemente ser excluidas de la visualización por DRAW_NONE.

Inténtalo de esta manera:

...
//--- Проверяем, нужно ли отображать объемы
   if(inpUseArrows) // Если отображать нужно
     {
      SetPlotParametersArrow(1,2,bufArrowUp,false,"test up",EMPTY,clrLime,233,10);
      SetPlotParametersArrow(2,3,bufArrowDn,false,"test dn",EMPTY,clrRed,234,-10);
     }
   else
     {
      //--- Устанавливаем тип графического построения
      PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_NONE);
      PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_NONE);
     }

...

 
Anatoli Kazharski:

Independientemente de que se especifiquen matrices para las flechas como búferes, éstas siguen siendo rígidas:

//---

Alternativamente, si las flechas no necesitan ser mostradas, pueden simplemente ser excluidas de la visualización por DRAW_NONE.

Prueba esta variante:

Lo he pensado, pero esto tiene una desventaja. Las matrices se marcarán y ampliarán automáticamente, consumiendo recursos. Será mejor que los desarrolladores dejen que se arregle el fallo.

¿Y qué hay de la codificación de los datos... Si no vinculo los búferes a las series gráficas, ¿por qué veo una basura desconocida de la que no puedo deshacerme?

De lo contrario, resulta que los indicadores dinámicos no pueden construirse normalmente.

La opción más ideal es limpiar los buffers en deinit y listo. Pero la limpieza no ayuda...

 

En ME, por favor muestre ALT+M en la lista de funciones/métodos el tipo de valor de retorno.

 

Estaría bien introducir una distinción en el tipo de cadena tal y como se utiliza en otros lenguajes a una cadena ordinaria y una cadena "cruda". Creo que llegaremos a esto de todos modos, pero en la etapa inicial eliminaría muchos problemas en el futuro.

Por ejemplo, Python utiliza r "cadena" para crear una cadena "cruda"
 

¿Cuál es la razón de que no salgan del todo los registros en el probador? Todo lo que se puede mirar ha sido mirado y comprobado, no se puede superar.

 
Andrey Dik:

¿Cuál es la razón de que los registros no se muestren completamente en el probador? Todo lo que se puede mirar - mirar y comprobar, no se puede vencer.

Muchas entradas. Ver archivo de registro.

Razón de la queja: