OnCalculate function not found in custom indicator 1 1 ошибка при компиляции

 

Добрый день, пытаюсь компилировать советник из учебника, выводит ошибку "OnCalculate function not found in custom indicator 1 1"

Насколько я поискала в интернете, проблема в отсутствии обязательной функции - OnCalculate, как решение предлагается добавить пустую функцию, но это не помогает... Буду очень признательна, если кто-то подскажет, как это обойти или исправить.. ну или что в этой функции должно быть прописано..

код беру по ссылке из документации - https://book.mql4.com/ru/samples/icustom (самый первый пример), приведен ниже.

//--------------------------------------------------------------------
// userindicator.mq4 
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
#property indicator_chart_window    // Индик. рисуется в основном окне
#property indicator_buffers 2       // Количество буферов
#property indicator_color1 Blue     // Цвет первой линии
#property indicator_color2 Red      // Цвет второй линии
 
double Buf_0[],Buf_1[];             // Объявление массивов (под буферы индикатора)
//--------------------------------------------------------------------
int init()                          // Специальная функция init()
  {
   SetIndexBuffer(0,Buf_0);         // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Стиль линии
   SetIndexBuffer(1,Buf_1);         // Назначение массива буферу
   SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);// Стиль линии
   return;                          // Выход из спец. ф-ии init()
  }
//--------------------------------------------------------------------
int start()                         // Специальная функция start()
  {
   int i,                           // Индекс бара
       Counted_bars;                // Количество просчитанных баров 
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Количество просчитанных баров 
   i=Bars-Counted_bars-1;           // Индекс первого непосчитанного
   while(i>=0)                      // Цикл по непосчитанным барам
     {
      Buf_0[i]=High[i];             // Значение 0 буфера на i-ом баре
      Buf_1[i]=Low[i];              // Значение 1 буфера на i-ом баре
      i--;                          // Расчёт индекса следующего бара
     }
//--------------------------------------------------------------------
   return;                          // Выход из спец. ф-ии start()
  }
//--------------------------------------------------------------------
 
этот пример используется для пробы - итог советник с пользовательским индикатором
 

Это устаревший учебник. Сейчас этот пример должен быть таким.

//+------------------------------------------------------------------+
//|                                                userindicator.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2       // Количество буферов
#property indicator_color1 Blue     // Цвет первой линии
#property indicator_color2 Red      // Цвет второй линии
double Buf_0[],Buf_1[];             // Объявление массивов (под буферы индикатора)
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Buf_0);                     // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);   // Стиль линии
   SetIndexBuffer(1,Buf_1);                     // Назначение массива буферу
   SetIndexStyle (1,DRAW_LINE,STYLE_DOT,1);     // Стиль линии
//---
   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 i;                           // Индекс бара
   //Counted_bars=IndicatorCounted(); Пока работает, НО этим лучше не пользоваться
   //i=Bars-Counted_bars-1;           И этим лучше не пользоваться
   
   i = rates_total-prev_calculated-1;// Индекс первого непосчитанного
    while(i >= 0)                      // Цикл по непосчитанным барам
     {
      Buf_0[i]=High[i];             // Значение 0 буфера на i-ом баре
      Buf_1[i]=Low[i];              // Значение 1 буфера на i-ом баре
      i--;                          // Расчёт индекса следующего бара
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Огромное спасибо! Компилируется, в коде теперь разберусь))
 

Подскажите пожалуйста почему моя заготовка индикатора не прикрепляется к графику. 

Я написал функцию которая считывает внешний *.csv в массив. Проверил - функция сама по себе работает.

Добавил пару деклараций для будущего индикатора, и мой индикатор перестал коннектиться к графику. Есть подозрения что это из-за OnCalculate()

Этот код работает нормально:

#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

string main_array[2][100];

int OnInit()
  {

   string file_name = "GSPC.csv";
   string delimeter = ",";

   Alert("Function started");
   csv_array(file_name, delimeter, main_array);
   Alert("Function stopped");
    
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//---
   
  }

void OnTick()
  {
   
  }
//+------------------------------------------------------------------+
void csv_array(string file_name, string delimiter, string &main_array1[][])
{
// ------------------------

   int cols = ArrayRange(main_array1, 0);
   int rows = ArrayRange(main_array1, 1);
   Alert(cols, " ", rows);
   
   int handle = FileOpen(file_name, FILE_CSV|FILE_READ, delimiter);
   Alert(handle);

   if(handle == 1)
   {
      for (int row = 0; row < rows; row++ )
      {
         Alert("loop_started");
         for (int col = 0; col < cols; col++ )
         {
            Alert("inner_loop_started");
            main_array1[col][row] = FileReadString(handle);
            Alert(main_array1[col][row]);
         }
      }
   }
   Alert("loop_stopped");
   FileClose(handle);
   return;
}

 

 А этот уже не работает: 

 

//+------------------------------------------------------------------+
//|                                                      testone.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue

//extern int history = 100;
 
double Buf_0[];
string main_array[2][100];
//string main_array[][];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  SetIndexBuffer(0, Buf_0);
  SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
  
//---
   string file_name = "GSPC.csv";
   string delimeter = ",";

   Alert("Function started");
   csv_array(file_name, delimeter, main_array);
   Alert("Function stopped");
    
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//   int i,
//       counted_bars;
//---
//   counted_bars = IndicatorCounted();
//   i = Bars - counted_bars -1;
//   if ( i > history-1 ) i = history - 1;
//   while(i >= 0)
//   {
//      Buf_0[i]=main_array[2][i];
//   }
   
   
  }
//+------------------------------------------------------------------+
void csv_array(string file_name, string delimiter, string &main_array1[][])
{
// ------------------------
// Объявление переменных
   int cols = ArrayRange(main_array1, 0);
   int rows = ArrayRange(main_array1, 1);
   Alert(cols, " ", rows);
   
// Открыть файл CSV для чтения с указателем ","
   int handle = FileOpen(file_name, FILE_CSV|FILE_READ, delimiter);
   Alert(handle);
//+------------------------------------+
//| Узнать количество позиций в строке |
//+------------------------------------+
   if(handle == 1)
   {
      for (int row = 0; row < rows; row++ )
      {
         Alert("loop_started");
         for (int col = 0; col < cols; col++ )
         {
            Alert("inner_loop_started");
            main_array1[col][row] = FileReadString(handle);
            Alert(main_array1[col][row]);
         }
      }
   }
   Alert("loop_stopped");
   FileClose(handle);
// ----------------------------------
   return;
}

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[]) 
  {
   return(rates_total);
  }

 

*.csv который я использую есть во вложении.

Спасибо большое за ваше внимание! =) 

Файлы:
gspc.zip  2 kb
 
Правильно делает... Если тебе дать команду "Стой там. Иди сюда" что ты будешь делать и что ты скажешь о таком командире??? А сам ставишь две команды OnTick() и OnCalaulate() вместе, не зависимо от того что они обе пустые и думаешь что программа тебе ничем не ответит...