Calculating SMA50 Line in EA

 

I have two options here, either I can:


Retrieve data points from custom indicator

or

Retrieve data points by means of recreating the sma50 line.


The easiest thing to do (I imagine) would be to retreive from a custom indicator. The SMA50 line is drawn on the chart by the indicator. How can I extarct data points from this line?

 

This is what I've got so far:


double SMA50;

SMA50=iMA(NULL,0,16,2,MODE_SMA,PRICE_CLOSE,0);

Print(SMA50);


The problem is that it seems to be tracking the SMA10 line rather than the SMA50 line. How do I adjust this correctly?

 
mixtermind wrote >>

This is what I've got so far:

double SMA50;

SMA50=iMA(NULL,0,16,2,MODE_SMA,PRICE_CLOSE,0);

Print(SMA50);

The problem is that it seems to be tracking the SMA10 line rather than the SMA50 line. How do I adjust this correctly?

double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

in your example you have 16 for the ma-period and 2 for the shift.

Try SMA50=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);

 
Sometimes the siimplest answers are in fact the correct ones. Thanks a bunch EADeveloper :-)
Reason: