Moving average indicator

 
Hi

I have an indicator for moving average and I want to create an expert adviser with it myself but I need help on how to find the price of the 3rd candle along (this can change depending on what the user inputs) and the candle just closed and then minus each other and compare the result if this result is a minus then the calculation needs to be put the opposite way so the result is always a positive figure), to the criteria inputted by the user. If this is greater than what the user inputted then a true needs to be put in an array.


Also the range of bars that is looked at needs to be inputted by the user so it could be the last 3, 4, 5, candles etc depending on what the user puts in.

Also how can I display a message to show this bit of the code as worked.


Any help on this would be appreciated

Carl
 


https://www.mql5.com/en/articles/1496
This page may help about half way done it starts talking about technical indicators and how to fetch the values you want.
You can also use MathAbs() function to always return a positive value.

 
Thanks for that Ickyrus

I am taking this one stage at a time.

I want to check that this code works so this code should add the previous closed price for the moving average as a chart comment but it keeps showing zero anyone know why this is

double MA;


MA=iMA("0",0,50,0,MODE_SMMA,PRICE_CLOSE,1);
// moving average of the last bar on a daily chart EURCHF.
// Use 18 bars and typical price for finding smoothed moving average.
// Shift: 4 bars.


Print("Moving average price is",iMA("0",0,50,0,MODE_SMMA,PRICE_CLOSE,1));


Comment("Moving average price is",iMA("0",0,50,0,MODE_SMMA,PRICE_CLOSE,1));