Hi all, I've found this article about how to add custom indicator to ea. in my code I already create a variable for the input and create the indicator using iCustom function. But when I backtested, it tells me about 4051 error code which is invalid function parameter. Anyone can help me with this error?
what is your "ema" indicators inputs?
and is there an indicator in your indicators folder?
what is your "ema" indicators inputs?
and is there an indicator in your indicators folder?
double MA_Period[2] = {9,21}; double coef = 0.0; int MA_Shift = 0; int SetPrice = 0;
That’s the parameter that my custom ema indicator need. I don’t use input cause I want it to be static. I already copy the custom ema indicator into the indicator folder also.
That’s the parameter that my custom ema indicator need. I don’t use input cause I want it to be static. I already copy the custom ema indicator into the indicator folder also.
if you have an indicator in your indicator folder which name is same "ema" , and you want to use its default parameters try this
may be it helps
//+------------------------------------------------------------------+ double MA_Period1=9; double MA_Period2=21; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double EMA1 = iCustom(Symbol(),0,"ema",MA_Period1,0,0); double EMA2 = iCustom(Symbol(),0,"ema",MA_Period2,0,0); //+------------------------------------------------------------------+
That’s the parameter that my custom ema indicator need. I don’t use input cause I want it to be static. I already copy the custom ema indicator into the indicator folder also.
Through iCustom you can send parameters only for the indicator variables that have input or external keyword.
If you removed "input"/"external" keywords from your indicator, then you can't send parameters via iCustom.
Through iCustom you can send parameters only for the indicator variables that have input or external keyword.
If you removed "input"/"external" keywords from your indicator, then you can't send parameters via iCustom.
So basically I can’t use iCustom function if it’s not input or external keyword? And the error 4051 is related to that?
So basically I can’t use iCustom function if it’s not input or external keyword? And the error 4051 is related to that?
You can use iCustom even If your indicator does not have any input/extern variables, but you can't send parameters other than minimum required by iCustom.
ERR_INVALID_FUNCTION_PARAMVALUE 4051 - you get because you missed parameters by type and count.
Check that you use correct values for the first 3 and the last two parameters defined in iCustom.
If you don't have input/extern variables in your indicator, you should use only those 5 values in iCustom call.
- docs.mql4.com
double MA_Period[2] = {9,21}; double coef = 0.0; int MA_Shift = 0; int SetPrice = 0; double EMA1 = iCustom(NULL,0,"ema",MA_Period[0],coef,MA_Shift,SetPrice,0,0); double EMA2 = iCustom(NULL,0,"ema",MA_Period[1],coef,MA_Shift,SetPrice,0,0);
You were asked to provide the inputs of your ema.mq4. Why didn't you? Why do you want us to guess? I guess that the first input (MA_Period) is an int,
not a double.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all, I've found this article about how to add custom indicator to ea. in my code I already create a variable for the input and create the indicator using iCustom function. But when I backtested, it tells me about 4051 error code which is invalid function parameter. Anyone can help me with this error?