maryam mehraban #: hi, can you help me with error 4002 please?? none of my indicators (MA & RSI) can be loaded and i keep getting 4002 in strategy tester. and here is my code:
The first thing you should do is fix all the warning messages during the compile. Warnings may seem unimportant, but they can be the source of runtime errors. So, always pay attention and fix your compile warnings and errors so you get a clean compilation.
implicit conversion from'number' to 'string' TestEA.mq5 14456implicit conversion from'number' to 'string' TestEA.mq5 15057implicit conversion from'number' to 'string' TestEA.mq5 16346implicit conversion from'number' to 'string' TestEA.mq5 17248
possible loss of data due to type conversion from'uint' to 'int' TestEA.mq5 18717implicit conversion from'number' to 'string' TestEA.mq5 19863
possible loss of data due to type conversion from'uint' to 'int' TestEA.mq5 20617implicit conversion from'number' to 'string' TestEA.mq5 21465
You should always look up the meaning of error codes in the documentation, and in this case error 4002 means "Wrong parameter in the inner call of the client terminal function". So, it has nothing to do with it being an external or internal indicator, but about the parameters that you are using.
Now for your main question ... you have not defined an initial value for the "rsi_p" parameter nor are you testing it for valid values that will be acceptable for calling RSI. So obviously, if its value is invalid (example being set to 0), then it will throw a parameter error for it.
inputint rsi_p;
The same goes for the other indicator calls if you use invalid values. So, check the validity of those parameter values before calling the indicator functions.
Thank u so much. I defined initial value for rsi_p as you said, so everything seemed fine after debugging and both MA & RSI are loaded correctly. however, i still have problem backtesting.
strategy tester still shows 4002 error for MA (attached file), I checked the initial values for MA and nothing seems wrong :(
The first thing you should do is fix all the warning messages during the compile. Warnings may seem unimportant, but they can be the source of runtime errors. So, always pay attention and fix your compile warnings and errors so you get a clean compilation.
You should always look up the meaning of error codes in the documentation, and in this case error 4002 means "Wrong parameter in the inner call of the client terminal function". So, it has nothing to do with it being an external or internal indicator, but about the parameters that you are using.
Now for your main question ... you have not defined an initial value for the "rsi_p" parameter nor are you testing it for valid values that will be acceptable for calling RSI. So obviously, if its value is invalid (example being set to 0), then it will throw a parameter error for it. The same goes for the other indicator calls if you use invalid values. So, check the validity of those parameter values before calling the indicator functions.
@maryam mehraban#: Thank u so much. I defined initial value for rsi_p as you said, so everything seemed fine after debugging and both MA & RSI are loaded correctly. however, i still have problem backtesting. Strategy tester still shows 4002 error for MA (attached file), I checked the initial values for MA and nothing seems wrong :(
We cannot take your "word" that the initial values are correct. You should "show" that they are correct.
Show your new code where you have fixed all the problems, including the verification of the inputs as being valid.
Also, show the actual parameter values being used and reported in the Strategy Tester Journal log.
i would appreciate help from anyone but Mr. moderator! who is too busy labeling and judging amateurs.
There is no labelling or judgement.
Check your indicators calls and the parameters value.
Warnings may seem unimportant, but they can be the source of runtime errors.
So, always pay attention and fix your compile warnings and errors so you get a clean compilation.
— Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
So, it has nothing to do with it being an external or internal indicator, but about the parameters that you are using.
So obviously, if its value is invalid (example being set to 0), then it will throw a parameter error for it.
The same goes for the other indicator calls if you use invalid values.
So, check the validity of those parameter values before calling the indicator functions.
Thank u so much. I defined initial value for rsi_p as you said, so everything seemed fine after debugging and both MA & RSI are loaded correctly. however, i still have problem backtesting.
strategy tester still shows 4002 error for MA (attached file), I checked the initial values for MA and nothing seems wrong :(
Warnings may seem unimportant, but they can be the source of runtime errors.
So, always pay attention and fix your compile warnings and errors so you get a clean compilation.
— Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access
So, it has nothing to do with it being an external or internal indicator, but about the parameters that you are using.
So obviously, if its value is invalid (example being set to 0), then it will throw a parameter error for it.
The same goes for the other indicator calls if you use invalid values.
So, check the validity of those parameter values before calling the indicator functions.
We cannot take your "word" that the initial values are correct. You should "show" that they are correct.
Show your new code where you have fixed all the problems, including the verification of the inputs as being valid.
Also, show the actual parameter values being used and reported in the Strategy Tester Journal log.