Errores, fallos, preguntas - página 1093

 
zfs:
Vacío allí, a pesar de que el color se establece en el código. Con todo esto, el resultado positivo estaba ahí, pero desapareció, por ridículo que parezca).
Entonces un código corto que reproduzca el problema ayudaría a solucionarlo.
 
tol64:
Entonces, un código corto que reproduzca el problema ayudará.
#property indicator_separate_window

#property indicator_buffers 6                 // Количество буферов для расчёта индикатора
#property indicator_plots   2                 // Количество графических серий

#property  indicator_label1  "Open;High;Low;Close"

//перечисление методов отображения индикатора
enum ViewInd
  {
   Line,               // линии
   Bar,                // бары
   Candles             // свечи
  }; 
  
input ViewInd      _ViewInd= Line;     //вид индикатора  

double op[],cl[],hi[],lo[],s[];
double buffer_color_line[];//Буфер для индекса цвета



int OnInit()
  {
   for (int i=0;i<=5;i++)
    PlotIndexSetDouble(i,PLOT_EMPTY_VALUE,0);
   ArrayInitialize(op,0);ArrayInitialize(cl,0);  
   ArrayInitialize(hi,0);ArrayInitialize(lo,0);  
   ArrayInitialize(s,0);     

    
   if(_ViewInd==Line){
    SetIndexBuffer(5,s,INDICATOR_DATA);//Привязка массива к буферу
    PlotIndexSetInteger(5,PLOT_DRAW_TYPE,DRAW_LINE);
    PlotIndexSetInteger(5,PLOT_LINE_STYLE,STYLE_SOLID);
    PlotIndexSetInteger(5,PLOT_LINE_COLOR,clrRed);
    ArraySetAsSeries(s,true);
   }
   else{
   SetIndexBuffer(0,op,INDICATOR_DATA);
   SetIndexBuffer(1,hi,INDICATOR_DATA);
   SetIndexBuffer(2,lo,INDICATOR_DATA);
   SetIndexBuffer(3,cl,INDICATOR_DATA);
   SetIndexBuffer(4,buffer_color_line,INDICATOR_COLOR_INDEX);//Сопоставляем массив-буфер индексов цветов с буфером индикатора
   ArraySetAsSeries(op,true);
   ArraySetAsSeries(hi,true);
   ArraySetAsSeries(lo,true);
   ArraySetAsSeries(cl,true);   
   ArraySetAsSeries(buffer_color_line,true);      
//Задаем количество индексов цветов для графического построения
   PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,2);
   if (_ViewInd==Candles)PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_COLOR_CANDLES); else
    PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_BARS);
//Задаем цвет для каждого индекса
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,clrBlue);   //Нулевой индекс -> Синий
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrOrange); //Первый индекс  -> Оранжевый   
   }   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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 limit;//MQL 4 RULEZZZ
   int counted_bars=prev_calculated;
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=rates_total-counted_bars;
   
   for (int i=0;i<limit;i++){
    if(_ViewInd==Line)s[i]=MathRand();
    else{
     op[i]=MathRand();
     cl[i]=MathRand();
   if (op[i]>cl[i])buffer_color_line[i]=1;else buffer_color_line[i]=0;
     hi[i]=32767;
     lo[i]=0;        
    }  
   }

   return(rates_total);
  }
//+------------------------------------------------------------------+
Es algo así.
 
zfs:
Así.

Así es como aparecerán los valores después del nombre corto

for (int i=0;i<=5;i++)
    {PlotIndexSetDouble(i,PLOT_EMPTY_VALUE,0);};
Se trata del orden en los topes. https://www.mql5.com/ru/forum/12882#comment_539990
В каком порядке делать SetIndexBuffer() и зависит ли он он порядка директив #property indicator_x ?
В каком порядке делать SetIndexBuffer() и зависит ли он он порядка директив #property indicator_x ?
  • www.mql5.com
может ли кто-то на пальцах обьяснить правила привязки индикаторного буфера к опр.
 
Y cómo me ayuda, no entiendo nada). Se puede cambiar algo para que funcione, pero sigue estando torcido, y me gustaría saber más al respecto.
 
zfs:
Es algo así.

Caos y desorden total. ) Aquí hay una versión que funciona (corregí los errores y lo repasé):

//+------------------------------------------------------------------+
//|                                                        #Test.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
//---
#property indicator_buffers 5 // Количество буферов для расчёта индикатора
#property indicator_plots   1 // Количество графических серий
//---
#property  indicator_color1  clrDodgerBlue,C'0,50,100'
//--- Перечисление методов отображения индикатора
enum ViewInd
  {
   Line,   // линии
   Bar,    // бары
   Candles // свечи
  };
//--- Внешние параметры
input ViewInd _ViewInd=Line; // Вид индикатора  
//---
double op[],cl[],hi[],lo[];
double buffer_color_line[]; // Буфер для индекса цвета
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(_ViewInd==Line)
     {
      //--- Привязка массива к буферу
      SetIndexBuffer(0,cl,INDICATOR_DATA);
      //---
      PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);
      PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
     }
   else
     {
      SetIndexBuffer(0,op,INDICATOR_DATA);
      SetIndexBuffer(1,hi,INDICATOR_DATA);
      SetIndexBuffer(2,lo,INDICATOR_DATA);
      SetIndexBuffer(3,cl,INDICATOR_DATA);
      //--- Сопоставляем массив-буфер индексов цветов с буфером индикатора
      SetIndexBuffer(4,buffer_color_line,INDICATOR_COLOR_INDEX);
      //---
      if(_ViewInd==Candles)
         PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_CANDLES);
      else
         PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_BARS);
     }
//--- Установим метки для текущего таймфрейма
//    В режиме линия только цена закрытия
   if(_ViewInd==Line)
      PlotIndexSetString(0,PLOT_LABEL,"Close");
//--- В других режимах все цены баров/свеч
//    В качестве разделителя используется ";"
   else if(_ViewInd==Bar || _ViewInd==Candles)
      PlotIndexSetString(0,PLOT_LABEL,"Open;"+"High;"+"Low;"+"Close");
//---
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
//---
   ArrayInitialize(op,0);
   ArrayInitialize(cl,0);
   ArrayInitialize(hi,0);
   ArrayInitialize(lo,0);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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 limit=0; //MQL 4 RULEZZZ
//---
   if(prev_calculated==0)
      limit=0;
   else
      limit=prev_calculated-1;
//---
   for(int i=limit; i<rates_total; i++)
     {
      if(_ViewInd==Line)
         cl[i]=MathRand();
      else
        {
         op[i]=MathRand();
         cl[i]=MathRand();
         hi[i]=32767;
         lo[i]=1;
         //---
         if(op[i]>cl[i])
            buffer_color_line[i]=1;
         else
            buffer_color_line[i]=0;
        }
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

Cómo funciona

if(_ViewInd==Line){
}
   else{

if (_ViewInd==Candles)
else

si

enum ViewInd
  {
   Line,               // линии
   Bar,                // бары
   Candles             // свечи
  }; 

?

Vuelve a comprobar todas las condiciones y paréntesis, y sin un bucle, establece las propiedades del buffer de forma lineal, ordena desde el enlace anterior.

 
Silent:

...

Compruebe de nuevo todas las condiciones y paréntesis, y establezca las propiedades de la memoria intermedia de forma lineal sin un bucle, ordene desde el enlace anterior.

Ahí no se necesita un bucle en absoluto. Más concretamente, la propiedad sólo debe establecerse para un búfer, en todas las opciones de mapeo.
 
tol64:
No hay necesidad de un bucle en absoluto.
Generalmente sí, pero si hay muchos topes, es más corto :-) aunque yo no lo hago. Me resulta más fácil leer los retratos lineales.
 
Silent:
Generalmente sí, pero si hay muchos topes, es como más corto :-) aunque yo no lo hago. Es más fácil para mí leer portmanteaus lineales.
De hecho, puede haber tantos búferes (máximo 512), que es mucho más difícil leer el tejido sin bucles. ) En esta variante sólo hay un buffer.
 
tol64:
No hay necesidad de un bucle en absoluto.
Genial). Gracias. Como un reloj. El coñac se enfría).
Razón de la queja: