Индикатор рисуется не полностью.

 

Всем доброго дня. 

Почему-то не получается нарисовать свой индикатор длинной более чем на 60 тысяч баров. Хочу на пятиминутках посмотреть индикатор с начала 2018-го года, но получается увидеть его только с середины года. Если задаю параметр, чтобы рисовался с января, то график индикатора не рисуется вообще. В чем причина?

 
Reactor555:

Всем доброго дня. 

Почему-то не получается нарисовать свой индикатор длинной более чем на 60 тысяч баров. Хочу на пятиминутках посмотреть индикатор с начала 2018-го года, но получается увидеть его только с середины года. Если задаю параметр, чтобы рисовался с января, то график индикатора не рисуется вообще. В чем причина?

Надо индикатор прикласть в виде кода

 
Reactor555:

Всем доброго дня. 

Почему-то не получается нарисовать свой индикатор длинной более чем на 60 тысяч баров. Хочу на пятиминутках посмотреть индикатор с начала 2018-го года, но получается увидеть его только с середины года. Если задаю параметр, чтобы рисовался с января, то график индикатора не рисуется вообще. В чем причина?

А баров сколько на графике?

А сколько максимальное количество баров?

Критические ошибки?

 
Evgeny Belyaev:

А баров сколько на графике?

А сколько максимальное количество баров?

Критические ошибки?

На графике баров до 2016 года и дальше. Критических ошибок нет.

Чтобы посмотреть график на всем 2018-м, приходится менять таймфрейм на М15. 

 
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Relative Strength Index"
#property strict

#property indicator_separate_window
#property indicator_minimum    0
#property indicator_maximum    8
#property indicator_buffers    1
#property indicator_color1     Red
#property indicator_level1     3.0
#property indicator_level2     5.0
#property indicator_level3     6.0
#property indicator_level4     7.0
#property indicator_levelcolor clrYellow
#property indicator_levelstyle STYLE_DOT
#property  indicator_width1 2
//--- input parameters
input int InpRSIPeriod=20000; // RSI Period
input double Step = 0.0022; // RSI Step
int minuta;

//--- buffers
double ExtRSIBuffer[100000];
//--- variables
double Verh, Niz, nach, step2;
int i, pos;
datetime tnach;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   if ( ( Symbol() == "USDJPY" ) || ( Symbol() == "EURJPY" ) || ( Symbol() == "AUDJPY" ) )  { step2 = Step * 100; } else step2 = Step;

   string short_name;
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtRSIBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name="myRSI("+string(InpRSIPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- check for input
   if(InpRSIPeriod<2)
     {
      Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpRSIPeriod);
//--- initialization done
   pos = InpRSIPeriod;
   
   Print("Correct value for input variable InpRSIPeriod = ",InpRSIPeriod); 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   if ( pos > 0 )
    {
     ...
   for ( i = InpRSIPeriod - 1; i >= 1; i-- )
    {

     .....

    ExtRSIBuffer [ i ] = .....

     pos = 0; 
    }
    
    } else
    {
     i = 1;

    ...

    ExtRSIBuffer [ i ] = ....

    }  
   return(0);
  }
//+------------------------------------------------------------------+

MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader
MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader
  • www.mql4.com
MQL4: automated forex trading, strategy tester and custom indicators with MetaTrader
 
Reactor555:
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Relative Strength Index"
#property strict

#property indicator_separate_window
#property indicator_minimum    0
#property indicator_maximum    8
#property indicator_buffers    1
#property indicator_color1     Red
#property indicator_level1     3.0
#property indicator_level2     5.0
#property indicator_level3     6.0
#property indicator_level4     7.0
#property indicator_levelcolor clrYellow
#property indicator_levelstyle STYLE_DOT
#property  indicator_width1 2
//--- input parameters
input int InpRSIPeriod=20000; // RSI Period
input double Step = 0.0022; // RSI Step
int minuta;

//--- buffers
double ExtRSIBuffer[100000];
//--- variables
double Verh, Niz, nach, step2;
int i, pos;
datetime tnach;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   if ( ( Symbol() == "USDJPY" ) || ( Symbol() == "EURJPY" ) || ( Symbol() == "AUDJPY" ) )  { step2 = Step * 100; } else step2 = Step;

   string short_name;
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtRSIBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name="myRSI("+string(InpRSIPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- check for input
   if(InpRSIPeriod<2)
     {
      Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpRSIPeriod);
//--- initialization done
   pos = InpRSIPeriod;
   
   Print("Correct value for input variable InpRSIPeriod = ",InpRSIPeriod); 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   if ( pos > 0 )
    {
     ...
   for ( i = InpRSIPeriod - 1; i >= 1; i-- )
    {

     .....

    ExtRSIBuffer [ i ] = .....

     pos = 0; 
    }
    
    } else
    {
     i = 1;

    ...

    ExtRSIBuffer [ i ] = ....

    }  
   return(0);
  }
//+------------------------------------------------------------------+

А вставить всю эту фигню в "Код" религия не позволила?

 
Сергей Таболин:

А вставить всю эту фигню в "Код" религия не позволила?

Как это делается?

 
Reactor555:

Как это делается?

Сверху, когда новое сообщение готовите, поищите. 

 
Reactor555:
input int InpRSIPeriod=20000; // RSI Period
input double Step = 0.0022; // RSI Step
int minuta;

//--- buffers
double ExtRSIBuffer[100000];
//--- variables
double Verh, Niz, nach, step2;
int i, pos;
datetime tnach;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   if ( ( Symbol() == "USDJPY" ) || ( Symbol() == "EURJPY" ) || ( Symbol() == "AUDJPY" ) )  { step2 = Step * 100; } else step2 = Step;

   string short_name;
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtRSIBuffer);
//--- name for DataWindow and indicator subwindow label
   short_name="myRSI("+string(InpRSIPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- check for input
   if(InpRSIPeriod<2)
     {
      Print("Incorrect value for input variable InpRSIPeriod = ",InpRSIPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpRSIPeriod);
//--- initialization done
   pos = InpRSIPeriod;
   
   Print("Correct value for input variable InpRSIPeriod = ",InpRSIPeriod); 
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   if ( pos > 0 )
    {
     ...
   for ( i = InpRSIPeriod - 1; i >= 1; i-- )
    {

     .....

    ExtRSIBuffer [ i ] = .....

     pos = 0; 
    }
    
    } else
    {
     i = 1;

    ...

    ExtRSIBuffer [ i ] = ....

    }  
   return(0);
  }
//+------------------------------------------------------------------+

С настройками по умолчанию рассчитан на 20 000 баров. Если на графике меньше баров то должен завершить работу с критической ошибкой(выход за пределы массива).
 
Да. Если я ставлю вместо 20000 любое число до 60000, то график рисуется без проблем. Если больше 60000, то не рисуется.
 
Reactor555:
Да. Если я ставлю вместо 20000 любое число до 60000, то график рисуется без проблем. Если больше 60000, то не рисуется.

С таким подходам вам во фриланс.

Причина обращения: