Previous Indicator On Expect Advisor

 
Hi, I have googled all night, I still seem not to find the right code. The MetaEditor does not have the previous indicator. I am trying to build a MA EA but now I need the previous Indicator.

This is what I got off the internet and cant figure out how to use it.


double iMAOnArray(

double array[], // array with data

int total, // number of elements

int ma_period, // MA averaging period

int ma_shift2, // MA shift

int ma_method, // MA averaging method int shift, // shift );

   double macurrent = iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,0);
   double macurrentslow = iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,0);
   double maprev = iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,1);
   double maprevslow = iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,1);
   //----
   if(maprev<maprevslow && macurrent>=macurrentslow)
     Alert("crossing up");

for(int i=0; i<limit; i++)
   First_MA[i] = iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i);

   for(i=0; i<limit; i++)
   Second_MA[i]   = iMAOnArray(First_MA,0,14,0,MODE_SMA,i);
 

First question - is this supposed to be MQL4 or 5?

What is this?

double iMAOnArray(

double array[], // array with data

int total, // number of elements

int ma_period, // MA averaging period

int ma_shift2, // MA shift

int ma_method, // MA averaging method int shift, // shift );

It seems to be the function copied from MQL4 documentation which has no place in your code.

Anyway it should be

double iMAOnArray(

double array[], // array with data

int total, // number of elements

int ma_period, // MA averaging period

int ma_shift2, // MA shift

int ma_method, // MA averaging method

int shift, // shift
 
);

and is used for reference. It should not be copied into your code as it is.

Reason: