what's wrong with my program? by a mql4 newbie...

To add comments, please log in or register
tradingmachine
5
tradingmachine  
hello folks. i just get started learning the powerful MQL4 and try to write some simple program. I want the MT4 to remind me that the last candle line was a small one which has short true range and i want it to remind me for 5 times by a sound. So i wrote the following lines.

extern double v=0.05;
extern int Temp=0;
double Points;
int init ( )
{
Points = MarketInfo (Symbol( ), MODE_POINT);

return(0);
}
int deinit( )
{
return(0);
}
int start( )
{
if(High[1]-Low[1]> v )
{
Temp=0;}

if(High[1]-Low[1]<=v&&
Temp!=5)
{
Alert(Symbol( )," had a small candle line"); PlaySound("alert.wav");
Temp++;
}


}

i compiled it and there was no errors. However, when i used it in trading, it kept playing the sound without stopping. i have checked it but i dont know what's wrong with my work. Could you please help me to resolve this problem? thank you in advance.
fxdk
17
fxdk  
The problem seems to be that you're checking if Temp!=5
Try checking Temp<5

if(High[1]-Low[1]<=v&&
Temp!=5)
{
Alert(Symbol( )," had a small candle line"); PlaySound("alert.wav");
Temp++;
}
To add comments, please log in or register