how can i setup a alert when closeprice come to my aim?

 
I want to make a programe in MQL4,but it doesn't work.

please give me a programe. thanks!


            
 
Try this code.

It will alert you when the close price of the current bar is equal to or above the target price.
The target price is an external double so it is adjustable from the input parameters.
It will reset itself if the price goes back below the target.

I am self taught so there may be a better way..

//+------------------------------------------------------------------+
//| Alert.mq4 |
//| mpfx |
//| http://www.stideas.com |
//+------------------------------------------------------------------+
#property copyright "mpfx"
#property link "http://www.stideas.com"

extern double target = 1.2816;

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
static int flag;

if (flag ==0)
if ( Close[0]>=target)
{
Alert(" Target Priced reached ", Close[0]);

Print(" Target Reached ",Close[0]);

flag = 1 ;
}

if ( Close[0]<target )

{flag = 0;}

}
//+------------------------------------------------------------------+
 
Thank you very much for your programe! It is ok.

but,the voice of alert in this file is short.
I want a continous voice of alert , which is different from the voice made when system recieving datas.
by the way ,i don't know how to use the syntax "playsound( ) ".

I hope I can hear the alert clearly when I don't watch the screen.
please give me a hand again!
 
Follow this....
1. From MT4 main window, click tools / options.

2. Select the event tab.

3. Scroll down to Alert.

4. Double click alert.wav and a drop down menu will appear.

5. Select the desired sound from list or select Choose other.
If you select Choose other you will be able to navigate to any available sounds on your pc.
Select All files if you want a sound other than a .wav file.
I have my favorite song selected which opens windows media player and plays continually till I close it down.

GT.........
Reason: