I am modifying the alligator indicator.
I want it to send me a screen alert when the green line crfosses the red line but it does this constantly, not just once and then again on the next cross
Any ideas:
Crossed function:
I want it to send me a screen alert when the green line crfosses the red line but it does this constantly, not just once and then again on the next cross
Any ideas:
for(int i=0; i<limit; i++)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
ExtBlueBuffer=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtRedBuffer=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
//Print(iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i));
ExtLimeBuffer=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
int isCrossed = Crossed (iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i),iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i));
//if (isCrossed==1) {Alert("Teeth have crossed lips");}
}
Crossed function:
int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_direction = 0;
if(line1>line2)current_direction = 1; //up
if(line1<line2)current_direction = 2; //down
if(current_direction != last_direction) //changed
{
last_direction = current_direction;
return (last_direction);
}
else
{
return (0);
}
}