Hi guys,
i downloaded a simple Moving Average Price Alert here some time ago.
Unfortunately i'm having trouble getting the alert to play a custom sound (i.e i cannot choose my own wav sound file); the indicator simply keeps defaulting to the standard alert.wav file in the MT4 sounds folder..
can anyone help??!? im going crazy, cant seem to figure out whats wrong with the code!!
code below (and attached)
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 = "timeout.wav"; //<-- i've changed this to "timeout.wav" yet it still plays alert.wav!!!?????
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(Sound_File);
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);
}
//+------------------------------------------------------------------+