IndicatorParameters giving error 4014

To add comments, please log in or register
Stefano Giacone
231
Stefano Giacone  

 Hi, this code, when run, give me error 4014. Can you guess why? I copied it from https://www.mql5.com/en/docs/series/indicatorparameters

Thanks 

//+------------------------------------------------------------------+
//|                                                testIndicator.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

int h_ma1   = INVALID_HANDLE;
double ma1_buffer[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   h_ma1=iMA(Symbol(),PERIOD_CURRENT,10,0,MODE_SMA,PRICE_TYPICAL);
   if(h_ma1==INVALID_HANDLE) {
      Alert("INVALID_HANDLE");
   }
   
   CopyBuffer(h_ma1,0,0,3,ma1_buffer);
   ArraySetAsSeries(ma1_buffer,true);
   
   
         MqlParam parameters[];
         ENUM_INDICATOR indicator_type;
         int params=IndicatorParameters(h_ma1,indicator_type,parameters);
         Alert("Number of parameter: ", params);
         Alert("Last error:",GetLastError());
         //--- The header of the message
         string par_info="Indicator type "
                         +EnumToString(ENUM_INDICATOR(indicator_type))+"\r\n";
         //--- 
         for(int p=0;p<params;p++)
           {
            par_info+=StringFormat("parameter %d: type=%s, long_value=%d, double_value=%G,string_value=%s\r\n",
                                   p,
                                   EnumToString((ENUM_DATATYPE)parameters[p].type),
                                   parameters[p].integer_value,
                                   parameters[p].double_value,
                                   parameters[p].string_value
                                   );
           }
         Print(par_info);


  }
//+------------------------------------------------------------------+
Documentation on MQL5: Timeseries and Indicators Access / IndicatorParameters
Documentation on MQL5: Timeseries and Indicators Access / IndicatorParameters
  • www.mql5.com
Timeseries and Indicators Access / IndicatorParameters - Documentation on MQL5
Alain Verleyen
36140
Alain Verleyen  
What you posted here is an EA not an indicator. The code provided in the documentation (your link) is a script, not an indicator. You can't mix all type of programs.
Stefano Giacone
231
Stefano Giacone  
angevoyageur:
What you posted here is an EA not an indicator. The code provided in the documentation (your link) is a script, not an indicator. You can't mix all type of programs.

you're right! But how can I get IndicatorParameters inside an EA?

Is this not possible? 

Alain Verleyen
36140
Alain Verleyen  
johntiror:

you're right! But how can I get IndicatorParameters inside an EA?

Is this not possible? 

Of course it's possible. Your EA seems ok, provided that you define/save/run it as an EA.

Stefano Giacone
231
Stefano Giacone  
angevoyageur:

Of course it's possible. Your EA seems ok, provided that you define/save/run it as an EA.

Good. But it give me error 4014, why? (I defined/saved/run it as an EA)
Alain Verleyen
36140
Alain Verleyen  
johntiror:
Good. But it give me error 4014, why? (I defined/saved/run it as an EA)
Do you read and understand what I wrote ? Where is located your mq5 file ?
Stefano Giacone
231
Stefano Giacone  
angevoyageur:
Do you read and understand what I wrote ? Where is located your mq5 file ?
I'm used to code EA, so I know what I'm doing. I have this error in tester. If I attached it to the chart I have error 4006...
Alain Verleyen
36140
Alain Verleyen  
johntiror:
I'm used to code EA, so I know what I'm doing. I have this error in tester. If I attached it to the chart I have error 4006...

You never mentioned error (4014) was in the tester up to now...I guess I have to read your mind. Will check.

Stefano Giacone
231
Stefano Giacone  
angevoyageur:

You never mentioned error (4014) was in the tester up to now...I guess I have to read your mind. Will check.

Sorry!! My fault...
Alain Verleyen
36140
Alain Verleyen  
johntiror:
I'm used to code EA, so I know what I'm doing. I have this error in tester. If I attached it to the chart I have error 4006...
  • After some tests. You can get rid of error 4006 by using GetLastError() function only when there is an error with IndicatorParameters()
   if(params==-1) Print("Last error:",GetLastError());

But it's weird that GetLastError() reports an error when there is not.

  • About Strategy Tester. IndicatorParameters() doesn't work, which seems logical as there is no point to use a function to retrieve indicator's parameters when you can only use your own indicator (and so your are supposed to know the parameters).

ERR_FUNCTION_NOT_ALLOWED

4014

System function is not allowed to call

Stefano Giacone
231
Stefano Giacone  
angevoyageur:
  • After some tests. You can get rid of error 4006 by using GetLastError() function only when there is an error with IndicatorParameters()

But it's weird that GetLastError() reports an error when there is not.

  • About Strategy Tester. IndicatorParameters() doesn't work, which seems logical as there is no point to use a function to retrieve indicator's parameters when you can only use your own indicator (and so your are supposed to know the parameters).

ERR_FUNCTION_NOT_ALLOWED

4014

System function is not allowed to call

Thank you very much, really appreciated. I was using this function because I want to use the same indicator with different parameters (variable parameters), but I don't want to use IndicatorRelease if I'm using the same parameters.

Thnks again! 

To add comments, please log in or register