How to use custom indicator in MT4?

Hi there.

I’m working on an EA in MT4 and would like now to add a new custom indicator and run it from EA via “iCustom” function. Since I have all the data calculated in my EA (some kind of custom trend line), I would like to pass these values to the indi to draw them. However, this doesn’t seem possible or at least I don’t know how to do it. As much I’ve checked, all the preinstalled indi examples are made the way that they calculate the values to draw them selves and write these to the buffer array variables which are connected to graph lines. If possible I would need a bit different approch, that is: I calculate the values in an EA, store them into an array of doubles, and pass them to the indi. Has anyone does something similar yet? If this is not possible I need to copy all the calculation logic to the indi. Much thanks in advance for you help.

There is a way to handle passing a few variables by means of globals. Its worth taking a look at, but they are awkward to work with and may be too restrictive for your needs.

Like most tough problems, there probably is a way to do this with enough coding. But there is not some library function that does what you want. MT4 works by passing values from an indicator to an EA, but not the other way around.

Ok thanks, I got it, I’ll copy the code to indi.

For custom indicator, you must insert the indicator file to the folder installed metatrader in drive c:
Exactly, in “indicator” folder under “expert” folder of installed metatrader…

Then open metatrader and “insert custom indicator”, the indicator will listed there…