ФОРТС iCustom

 

Добрый день!

Пишет, что загружен, а на графике нет, как нет и в списке индикаторов! 

Пожалуйста попробуйте ФОРТС (может у меня с компом что-то)

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                        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 indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }

 

//+------------------------------------------------------------------+
//|                                                      LoadInd.mq5 |
//|                        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"

int sp_handle = INVALID_HANDLE;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  ResetLastError();
  sp_handle = iCustom( _Symbol, PERIOD_CURRENT, "Test"); 
  if ( sp_handle != INVALID_HANDLE )
  {
    MessageBox( "Indicator loaded! Last error = " + string( GetLastError() ), "Information", MB_OK);
     ChartIndicatorAdd( 0, 1, sp_handle );
  }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   if ( sp_handle != INVALID_HANDLE )
   IndicatorRelease( sp_handle );
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
 
Mikalas:

Добрый день!

Пишет, что загружен, а на графике нет, как нет и в списке индикаторов! 

Пожалуйста попробуйте ФОРТС (может у меня с компом что-то)

 

Как-то так

//+------------------------------------------------------------------+
//|                                                      LoadInd.mq5 |
//|                        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"

int sp_handle=INVALID_HANDLE;
string name_ind = "";
long id_ind = 0;
int wind_ind = 0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   MqlParam Param[1];
   Param[0].type=TYPE_STRING;
   Param[0].string_value="Test";
   sp_handle=IndicatorCreate(_Symbol,_Period,IND_CUSTOM,1,Param);
   if(sp_handle==INVALID_HANDLE)
      return(-1);
 
   id_ind = ChartID(); 
   wind_ind = (int)ChartGetInteger(id_ind,CHART_WINDOWS_TOTAL);  

   ChartIndicatorAdd(id_ind,wind_ind,sp_handle);
   int num = ChartIndicatorsTotal(id_ind, wind_ind);
   name_ind = ChartIndicatorName(id_ind, wind_ind, num-1);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   if(sp_handle!=INVALID_HANDLE)
   {    
    ChartIndicatorDelete(id_ind,wind_ind,name_ind);   
    IndicatorRelease(sp_handle);
   }   
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
 
MigVRN:

Как-то так

Зачем Вы это написали?

 
Mikalas:

Зачем Вы это написали?

То что у Вас написано - в принципе не может добавить индикатор на график и затем удалить его. В список тоже
 
MigVRN:
То что у Вас написано - в принципе не может добавить индикатор на график и затем удалить его. В список тоже

Объясните почему?

Кстати, то что Вы написали - не работает 

 
Mikalas:

Объясните почему?

Получить хэндл индикатора - и отобразить его на графике - это не одно и то же. Почитайте описание функций, которые я привел в коде. 

Если индикатор лежит в папке MQL5\Indicators - то будет работать. 

Добавлено: 

Хм...Или у меня галлюцинации, или изначально у Вас в первом посте  был несколько другой код. :) Изначально он у меня не работал.

То что ниже работает как надо. Только что проверил. На мой код выше можете внимания не обращать, но он рабочий + удаляет всё за собой после завершения работы.

//+------------------------------------------------------------------+
//|                                                      LoadInd.mq5 |
//|                        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"

int sp_handle = INVALID_HANDLE;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
  ResetLastError();
  sp_handle = iCustom( _Symbol, PERIOD_CURRENT, "Test"); 
  if ( sp_handle != INVALID_HANDLE )
  {
    MessageBox( "Indicator loaded! Last error = " + string( GetLastError() ), "Information", MB_OK);
     ChartIndicatorAdd( 0, 1, sp_handle );
  }
//---
  ChartRedraw();
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   if ( sp_handle != INVALID_HANDLE )
   IndicatorRelease( sp_handle );
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
 
MigVRN:

Получить хэндл индикатора - и отобразить его на графике - это не одно и то же. Почитайте описание функций, которые я привел в коде. 

Если индикатор лежит в папке MQL5\Indicators - то будет работать. 

Добавлено: 

Хм...Или у меня галлюцинации, или изначально у Вас в первом посте  был несколько другой код. :) Изначально он у меня не работал.

То что ниже работает как надо. Только что проверил. На мой код выше можете внимания не обращать, но он рабочий + удаляет всё за собой после завершения работы.

забыл поставит ChartIndicatorAdd() но не добавляет
 
Mikalas:
забыл поставит ChartIndicatorAdd() но не добавляет

Мой код из второго поста:

 

Пускай ещё кто-нибудь попробует. 

 
MigVRN:

Мой код из второго поста:

 

Пускай ещё кто-нибудь попробует. 

Спасибо, всё получилось.
Причина обращения: