What is the wrong with this code??

 

Hi All

I'm new to MQL4 I just start ... I'm trying to create alert to notify ( IF High OR Low touch Moving Average ) ONLY ONE ALERT PER BAR. This is the code made.

double LastSignal=0;

if( LastSignal != Time[0] )

{

double TouchFromDownM1 = (High[1] = MaCurrent_M1);

double TouchFromUpM1 = (Low[1] > MaPrevious1_M1 && Low [0] <= MaCurrent_M1);

if ( TouchFromDownM1 )

Alert("One Alert High Touch MA In 1M For : "+ Symbol(), " Cross Up");

if ( TouchFromUpM1 )

Alert("One Alert Low Touch MA In 1M For : "+ Symbol(), " Cross Down");

LastSignal = Time[0];

}

Any Help Will be appreciated .

 
savio:
Hi All

I'm new to MQL4 I just start ... I'm trying to create alert to notify ( IF High OR Low touch Moving Average ) ONLY ONE ALERT PER BAR. This is the code made.

double LastSignal=0;

if( LastSignal != Time[0] )

{

double TouchFromDownM1 = (High[1] = MaCurrent_M1);

double TouchFromUpM1 = (Low[1] > MaPrevious1_M1 && Low [0] <= MaCurrent_M1);

if ( TouchFromDownM1 )

Alert("One Alert High Touch MA In 1M For : "+ Symbol(), " Cross Up");

if ( TouchFromUpM1 )

Alert("One Alert Low Touch MA In 1M For : "+ Symbol(), " Cross Down");

LastSignal = Time[0];

}

Any Help Will be appreciated .

Change

double LastSignal=0;

to

static double LastSignal=0;

and it should work OK

 

Thanks so much

Reason: