Hatalar, hatalar, sorular - sayfa 1093

 
zfs :
Koddaki rengin ayarlanmış olmasına rağmen orada boş. Bütün bunlar için olumlu bir sonuç vardı, ama ne kadar saçma gelse de ortadan kayboldu).
Ardından sorunu yeniden üreten kısa bir kod anlamaya yardımcı olacaktır.
 
tol64 :
Ardından sorunu yeniden üreten kısa bir kod anlamaya yardımcı olacaktır.
 #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);
  }
//+------------------------------------------------------------------+
Aşağı yukarı böyle.
 
zfs :
Aşağı yukarı böyle.

Kısa addan sonra değerler bu şekilde görünür

 for ( int i= 0 ;i<= 5 ;i++)
    { PlotIndexSetDouble (i, PLOT_EMPTY_VALUE , 0 );};
Burada arabelleklerdeki sıra hakkında. https://www.mql5.com/en/forum/12882#comment_539990
В каком порядке делать SetIndexBuffer() и зависит ли он он порядка директив #property indicator_x ?
В каком порядке делать SetIndexBuffer() и зависит ли он он порядка директив #property indicator_x ?
  • www.mql5.com
может ли кто-то на пальцах обьяснить правила привязки индикаторного буфера к опр.
 
Ve bana nasıl yardımcı oluyor, hiçbir şey anlamadım). Bir şey değiştirilebilir ve bir şekilde işe yarayacaktır, ancak yine de eğri, ama daha kesin olarak bilmek istiyorum.
 
zfs :
Aşağı yukarı böyle.

Tam bir kaos ve kaos. ) Çalışan versiyonu koruyun (hataları düzeltildi ve tarandı):

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

Bu nasıl çalışır

 if (_ViewInd==Line){
}
   else {

if (_ViewInd==Candles)
else

Eğer

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

?

Tüm koşulları ve parantezleri yeniden kontrol edin ve bir döngü olmadan, arabelleklerin özelliklerini doğrusal olarak ayarlayın, sıra yukarıdaki bağlantıdandır.

 
Silent :

...

Tüm koşulları ve parantezleri yeniden kontrol edin ve bir döngü olmadan, arabelleklerin özelliklerini doğrusal olarak ayarlayın, sıra yukarıdaki bağlantıdandır.

Bir döngüye gerek yoktur. Daha doğrusu, özelliğin tüm görüntüleme seçeneklerinde yalnızca bir arabellek için ayarlanması gerekir.
 
tol64 :
Bir döngüye gerek yoktur.
Genel olarak evet, ancak çok fazla arabellek varsa, daha kısa olurdu :-) bunu yapmama rağmen. Doğrusal ayak örtülerini okumak benim için daha kolay.
 
Silent :
Genel olarak evet, ancak çok fazla arabellek varsa, daha kısa olurdu :-) bunu yapmama rağmen. Doğrusal ayak örtülerini okumak benim için daha kolay.
Aslında, o kadar çok tampon (en fazla 512) olabilir ki, ayak örtüsü döngüleri olmadan okunması çok daha zor olacaktır. ) Bu sürümde sadece bir arabellek vardır.
 
tol64 :
Bir döngüye gerek yoktur.
Süper). Teşekkür ederim. Saat gibi. Konyak soğuyor).