How to draw indicator buffers inside EA

After you’ve added a custom or built-in indicator inside EA using the iCustom() function, as you wish to use the buffers for trading decisions defined somewhere in EA, but after this a commonly sought requirement that anyone surely will scratch their head, how to display that buffer in charts as lines/arrows?

This might be frequently needed stuff, also in live markets it would be desirable to see the indicator activities.

This thing is quite simple to do, as we know that an EA cannot draw any buffers on its own so you need to apply the imported indicator whose handle one can obtain using iCustom() function.

You can do this by ChartIndicatorAdd() function inside OnInit()

void OnInit() {
int hAT=iCustom(Symbol(),0,"your_indicator_name");
ChartIndicatorAdd(0, 0, hAT);
}

Here the disappointing thing in MetaTrader is same indicator code is called again by EA, which can lead to resource overload, these are some of areas which MT4 isn’t great at!

Leave a Reply