How to code and add a MA line (Previous indicator data) on MACD ?

 

Hi

Anyone one who know How to code and add a MA line (Previous indicator data) on MACD ? I cannot find the way to add  MA line (Previous indicator data).


Eddie

 

Let me remind you that you are on the MQL5 forum and all the answers should be about MQL5.

Remember - in MQL5 the indicator handle is created ONCE and it is done in OnInit!

 
Cheung Man Wai:

Hi

Anyone one who know How to code and add a MA line (Previous indicator data) on MACD ? I cannot find the way to add  MA line (Previous indicator data).


Eddie

You want to apply an indicator "above/over" the results of another indicator.. like we do by dragging them on the chart, and using the field "previous indicator data" as a source? Right?

Programatically on MQL Language?


It is easy. 


// for example: Create a handle to some indicator, I will use Triple Exponencial here as an example:


int iTEMA_handle = INVALID_HANDLE;

// Load the indicator.. put some values.. price etc.. 
iTEMA_handle   = iTEMA(NULL,PERIOD_CURRENT,18,0,PRICE_WEIGHTED);


// Now lets create another indicator..(iAMA for example) and make it work on the Previous indicator data:
int iAMA_handle = INVALID_HANDLE;
iAMA_handle   = iAMA(NULL, PERIOD_CURRENT,44,2,65,0, iTEMA_handle);

//Notice that, instead of passing a PRICE as last argument of iAMA indicator, I passed the iTEMA handle!
// That is it.. 
// iAMA indicator will be applied over the result of the previous indicator data.. 





Notice that, instead of passing a PRICE as last argument of iAMA indicator, I passed the iTEMA handle (which is the handle of the previous indicator) as a source of PRICE. (last argument)

That is it..

iAMA indicator will be applied over the result of the previous indicator data.. 



I hope this is what you have asked for :) 

PS: Sometimes I understand and reply what was not the real purpuse of the OP question... because of lack of attention (defict of attention which I have at a very high level.. sorry.) please correct me if I did such mistake.