Добрый день!
Пишет, что загружен, а на графике нет, как нет и в списке индикаторов!
Пожалуйста попробуйте ФОРТС (может у меня с компом что-то)
Как-то так
//+------------------------------------------------------------------+ //| 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() { //--- } //+------------------------------------------------------------------+
Как-то так
Зачем Вы это написали?
Зачем Вы это написали?
То что у Вас написано - в принципе не может добавить индикатор на график и затем удалить его. В список тоже
Объясните почему?
Кстати, то что Вы написали - не работает
Объясните почему?
Получить хэндл индикатора - и отобразить его на графике - это не одно и то же. Почитайте описание функций, которые я привел в коде.
Если индикатор лежит в папке 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() { //--- }
Получить хэндл индикатора - и отобразить его на графике - это не одно и то же. Почитайте описание функций, которые я привел в коде.
Если индикатор лежит в папке MQL5\Indicators - то будет работать.
Добавлено:
Хм...Или у меня галлюцинации, или изначально у Вас в первом посте был несколько другой код. :) Изначально он у меня не работал.
То что ниже работает как надо. Только что проверил. На мой код выше можете внимания не обращать, но он рабочий + удаляет всё за собой после завершения работы.
Мой код из второго поста:
Пускай ещё кто-нибудь попробует.
Мой код из второго поста:
Пускай ещё кто-нибудь попробует.
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Вы принимаете политику сайта и условия использования
Добрый день!
Пишет, что загружен, а на графике нет, как нет и в списке индикаторов!
Пожалуйста попробуйте ФОРТС (может у меня с компом что-то)