Page 1 of 1

Alert once for fresh condition(Help)

Posted: Feb 13 2015
by goldmine
I've written code to alert when MA9 corss MA18(for example)
but when I excute the alert in 10 minites time frame
the Alert keeps triggered every 10 minute.
What I need is that it triggered once only until next condition meet again.

Thanks

Code: Select all

input:QQ(168), a1(9), a2(18);
var:ma1(0),ma2(0);
ma1=average(close,a1);
ma2=average(close,a2);
condition1= CurrentBar > 1 and ma1 cross over ma2;
condition2= CurrentBar > 1 and ma1 cross under ma2;
if condition1 or condition2 then
playsound("d:\sound\GC.wav") ;
Alert(GetSymbolName);

Re: Alert once for fresh condition(Help)

Posted: Feb 13 2015
by MAtricks
Cleaned up the code for you:

Code: Select all

INPUTS:
QQ( 168 ),
A1( 9 ),
A2( 18 ) ;

VARIABLES:
Ma1(0),
Ma2(0);

Ma1 = Average( C, A1 ) ;
Ma2 = Average( C, A2 ) ;

if Ma1 crossed over Ma2 then Alert( GetSymbolName ) ;
if Ma1 crossed under Ma2 then Alert( GetSymbolName ) ;
Also, check your alert settings setting and apply the sound file here:

Image

Re: Alert once for fresh condition(Help)

Posted: Feb 21 2015
by TJ
I've written code to alert when MA9 corss MA18(for example)
but when I excute the alert in 10 minites time frame
the Alert keeps triggered every 10 minute.
What I need is that it triggered once only until next condition meet again.

Thanks

Code: Select all

input:QQ(168), a1(9), a2(18);
var:ma1(0),ma2(0);
ma1=average(close,a1);
ma2=average(close,a2);
condition1= CurrentBar > 1 and ma1 cross over ma2;
condition2= CurrentBar > 1 and ma1 cross under ma2;
if condition1 or condition2 then
playsound("d:\sound\GC.wav") ;
Alert(GetSymbolName);
The problem is in your code...
you need a BEGIN and END block.

Code: Select all


input:QQ(168), a1(9), a2(18);
var:ma1(0),ma2(0);

ma1=average(close,a1);
ma2=average(close,a2);
condition1= CurrentBar > 1 and ma1 cross over ma2;
condition2= CurrentBar > 1 and ma1 cross under ma2;

if condition1 or condition2 then
BEGIN
playsound("d:\sound\GC.wav") ;
Alert(GetSymbolName);
END;

Re: Alert once for fresh condition(Help)

Posted: Feb 21 2015
by MAtricks
Hence the clean up I provided of that mess :)