Anyone knows how to deal with Error 4002?
-
I created this mql5 project using some MA crossings:
https://fxdreema.com/shared/0cGW7Cuad
I cannot backtest it because I get a weird error mesage saying: Error: Indicator not handled. (handle=-1 | error code=4002). Cannot load indicator 'Moving Average' [4002]
I never had an issie like this. These are the blocks including MA conditions:

I reviewed over and over and I simply can't see what the problem is. Could someone please take a look at it?

-
@l-andorrà Bro check your parameter types and positions carefully.
-
@talalkhan I did it more than 10 times and I see no problem! What do you mean?
-
@l-andorrà brother looks like something is out of date

or
a setting needs to be changed -
@l-andorrà
There can be one of these problem in your project
There is something wrong in your parameter or the other one is the indicator is not ready yet because You can't call iMA (or a function to get an indicator handle in general) and in the next statement use CopyBuffer, If you really used like this than change iMA in OnInit and CopyBuffer in Ontick. -
@alphaomega This is not the problem. I always empty that space and this is why you get that message. The error is somewhere in the MA, but I can't see where.
-
@talalkhan But what do you exactly mean by 'parameter'? Input parameter, variable or what?
-
@l-andorrà Sorry brother... then I do not know how to help you... up to the higher education then... good luck!!
-
@l-andorrà Yes¡¡ The same error I got on MT5 journals :(((((
-

Same error suffered 4002
I hate MT5 update
Post:
https://fxdreema.com/forum/topic/13653/indicator-fall-block -
@l-andorrà Is this just because every MA block is either switched off or has a switched off block above? I have never seen blocks work if above is switched off.
-
@jstap Well, as far as I checked them all, no MA block is switched off when the proper input indicator is selected. I tested that same logic on MT4 and it works fine, so the issue is in MT5 for sure. The admin needs to know this.
-
@l-andorrà Sometimes MT5 is different to MT4, shame but true.
-
When I tested this, I got error for RSI, not for MA. I deleted all unnecessary blocks until I ended up only with block 134 (and one Pass block). In this block, a Constant is used for "RSI period" and that Constant is named RSI_period.

I noticed that if I remove the Constant, the EA works. When I put it back - it gives me error 4002. So I focused on the Constant.
After some investigation I found the problem. Look at this screenshot:

I removed all Constants except RSI_period. But note that its Value is 0. This is interesting, because in the EA builder I changed it to 14. I also exported .mq5 file and changed the value there as well. However, it seems that there is some caching happening here and the value doesn't change when I change it in the code.
Such caching also happens in MT4, I'm aware about it, but there it only happens after I manually go to change any of these values. But this can only happen when I want to run the Optimization process, which is rare for me. So normally I never touch the Inputs. They are never cached, so I'm free to change the values of the Inputs in the project itself via the Constants.
Maybe they introduced this into MT5, to always cache the Inputs. And you see that error 4002, because some of your values are still 0. Turns out that if you try to run RSI or MA with period 0, this particular error appears. Its meaning in the documentation is "Wrong parameter in the inner call of the client terminal function"
-
@fxdreema So are you suggesting that we should not use any value 0 for any constant that is used on any indicator? I think I understand the problem, but not get the solution, sorry.
-
@l-andorrà said in Anyone knows how to deal with Error 4002?:
@fxdreema So are you suggesting that we should not use any value 0 for any constant that is used on any indicator? I think I understand the problem, but not get the solution, sorry.
Now I don't think that this is a new behaviour in MT5. I found that the files where these values are cached are located in MQL5/Profiles/Tester, they are .set files. I found many files there, almost as many EAs I have in MQL5/Experts. And these files are created since 2017 and even 2016.
Maybe nothing is different, maybe only now you have this problem with this EA, because it has too many Inputs and you forgot to set at least one of them.
I actually still do most of my tests in MT4, and I don't use Constants very often in my own projects. Only sometimes when I work on someone else's project I choose to change these values. And I normally assume that if someone shows me his project that contains Constants, the values for them are correct. So I don't have a good chance to fall into this problem. Also, when I have Constants/Inputs, I'm aware that they are there and I expect such problems.
I think that MetaTrader should alert us when there is a change in the Input values in the code, or maybe automatically change those values that are changed in the code.
-
@fxdreema What do you exactly mean by 'you forgot to set at least one of them'? All of them are set to 0 by default as you can see in the Constants. Should I remove any of those .set files? If so which ones?
-
@l-andorrà Do you find solution for this? Any hint?
-
@l-andorrà i have tried what change input with variable and it works.... see this screenshot

-
sorry still not working