Hi guys,
I downloaded a Moving Average Price Alert from here a while back [code below and attached].
Problem is- i cant seem to get a custom sound working. the script always defaults to the "alert.wav" style sound in the sounds folder..
i cant seem to change this even if trying PlaySound ("myownsound.wav") etc..
Appreciate any help!
I downloaded a Moving Average Price Alert from here a while back [code below and attached].
Problem is- i cant seem to get a custom sound working. the script always defaults to the "alert.wav" style sound in the sounds folder..
i cant seem to change this even if trying PlaySound ("myownsound.wav") etc..
Appreciate any help!
Inserted Code
//+------------------------------------------------------------------+ //| EMA-alert-Symbol-Period.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 1 //MODE_SMA 0 Simple moving average, //MODE_EMA 1 Exponential moving average, //MODE_SMMA 2 Smoothed moving average, //MODE_LWMA 3 Linear weighted moving average. //PRICE_CLOSE 0 Close price. //PRICE_OPEN 1 Open price. //PRICE_HIGH 2 High price. //PRICE_LOW 3 Low price. //PRICE_MEDIAN 4 Median price, (high+low)/2. //PRICE_TYPICAL 5 Typical price, (high+low+close)/3. //PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. //---- input parameters extern int ma_period = 24; extern int ma_mode = 0; extern int ma_price = 0; extern int ma_shift = 0; //---- buffers double ExtMapBuffer1[]; extern bool Box_Alert =true; extern bool Sound_Alert =true; extern string Sound_File = "C:\timeout.wav"; //<-- this does not play!! extern bool Email_Alert =false; extern int pip_distance = 100; datetime lastimealert; //---- double ema_value; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0, ExtMapBuffer1); //---- name for DataWindow and indicator subwindow label //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); //---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; limit = Bars - counted_bars; //---- string MA; for(int i = 0; i < limit; i++) { ema_value= iMA(NULL,0,ma_period,ma_shift,ma_mode,ma_price,i); if(ma_mode==0){MA="SMA";} if(ma_mode==1){MA="EMA";} if(ma_mode==2){MA="SMMA";} if(ma_mode==3){MA="LWMA";} //---- ExtMapBuffer1[i] = ema_value-Ask ; if(MathAbs(ema_value-Bid)<=pip_distance*Point&& lastimealert!= Time[0] ) { if(Box_Alert) Alert(Symbol()," M",Period()," Price is within ",pip_distance," pips of ",ma_period," Period "+MA+""); if(Sound_Alert) PlaySound("timeout.wav"); if(Email_Alert) SendMail("Price Alert on "+Symbol()+" M"+Period(),Symbol()+" M"+Period()+" Price is within "+pip_distance+" pips of "+ma_period+" Period "+MA+""); lastimealert= Time[0]; } } //---- return(0); } //+------------------------------------------------------------------+
Attached File(s)
MA-Price-Alert.mq4
3 KB
|
288 downloads