Anyone have some code that will sound a alert as the low of the previous bar is broken?
Never mind, I figured it out.
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern bool Show_Alert = true;
bool bSoundAlert = True; //
string sSoundFile = "Alert.wav";
int iDelayBetweenAlarm = 10; // delay between each alarm
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counter, setalert;
int alert = 0;
int counted_bars=IndicatorCounted();
//----
if (High[0] > High[1])
{
if(bSoundAlert && Show_Alert == true)Alerts(1);
}
//----
return(0);
}
//+------------------------------------------------------------------+
void Alerts(int Direction)
{
static datetime AlertLastTime = 0;
if(TimeCurrent() > AlertLastTime ) {
AlertLastTime = TimeCurrent()+iDelayBetweenAlarm;
PlaySound(sSoundFile);
}
}
Never mind, I figured it out.
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern bool Show_Alert = true;
bool bSoundAlert = True; //
string sSoundFile = "Alert.wav";
int iDelayBetweenAlarm = 10; // delay between each alarm
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counter, setalert;
int alert = 0;
int counted_bars=IndicatorCounted();
//----
if (High[0] > High[1])
{
if(bSoundAlert && Show_Alert == true)Alerts(1);
}
//----
return(0);
}
//+------------------------------------------------------------------+
void Alerts(int Direction)
{
static datetime AlertLastTime = 0;
if(TimeCurrent() > AlertLastTime ) {
AlertLastTime = TimeCurrent()+iDelayBetweenAlarm;
PlaySound(sSoundFile);
}
}