Change of Funtion output using static intergers

 
Hello,

I am working on modifying this code from "My first EA lesson" to return 1 the entire time the short moving average is above the long moving average, instead of only once at the crossing of the two.

Any Ideas?

Best Regards, Dale


int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;

if(line1>line2)current_dirction = 1; //up
if(line1<line2)current_dirction = 2; //down



if(current_dirction != last_direction) //changed
{
last_direction = current_dirction;
return (last_direction);
}
else
{
return (0);
}
}

double shortEma, longEma;

shortEma = iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,0);
longEma = iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,0);

int isCrossed = Crossed (shortEma,longEma);

If isCrossed = 1 // do other tasks