#SR_AlertSystem
Download scriptThis script is designed to serve as an automated notification tool for traders who want to be alerted the moment price movement interacts with specific horizontal levels on their trading chart. It acts as a watchful "sentinel," monitoring key price points and triggering alerts based on predefined rules.
Core Functionality
Level Identification & Visualization When you load this tool, it automatically identifies and places two primary visual markers on your chart: a Resistance level and a Support level. These appear as horizontal lines, allowing you to clearly see the boundaries of the current price action. You can customize their appearance, such as the color and thickness of the lines, to match your personal trading style.
The Alert Logic The script constantly monitors the relationship between the current market price and these two horizontal lines. It looks for two specific types of "piercing" actions:
- Resistance Break: If the price moves above the established Resistance line, the system recognizes a potential breakout.
- Support Break: If the price drops below the established Support line, the system recognizes a potential breakdown.
Customizable Sensitivity The tool offers two distinct ways to determine exactly when an alert should fire:
- Real-Time Movement: By default, the script can monitor the "live" price (the Bid), notifying you the very instant the market touches or crosses your lines.
- Confirmed Closure: You have the option to toggle a setting that requires a candle to actually close above or below the line before the alert triggers. This is useful for traders who want to avoid "false alarms" caused by temporary price spikes.
Notification Management To ensure you aren't overwhelmed with constant noise, the script includes an intelligent notification system:
- Audio Feedback: When a trigger occurs, it plays a specific sound file to grab your attention immediately.
- Time Buffering: It features a built-in delay mechanism. This prevents the system from triggering dozens of sounds in rapid succession for a single price movement, ensuring that you receive a clear, manageable notification.
//+------------------------------------------------------------------+
//| #SR_AlertSystem.mq4 |
//| Steve Fleming |
//| http://www.forexarea.com |
//+------------------------------------------------------------------+
#property copyright "Steve Fleming"
#property link "http://www.forexarea.com"
#property indicator_chart_window
extern bool AlarmOn = true; // alarm on or off?
extern bool SignalOnClose = false; // if false we will use Bid price to signal piercing of S/R levels
extern string ResistanceLineName = "R_Alert"; // name of SR line that will trigger Alarm
extern string SupportLineName = "S_Alert"; // name of SR line that will trigger Alarm
extern string SoundFile = "mrplow.wav"; // name of sound file
extern int DelayBetweenAlarm = 10; //
extern color SRLineClr = DarkOrchid; // color of SR lines
extern int SRLineWidth = 2; // width of SR lines
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
if(ObjectFind(ResistanceLineName) != 0){
ObjectCreate(ResistanceLineName, OBJ_HLINE, 0, 0,iHigh(NULL, 0, 0));
ObjectSet(ResistanceLineName, OBJPROP_COLOR, SRLineClr);
ObjectSet(ResistanceLineName, OBJPROP_WIDTH, SRLineWidth);
ObjectCreate(SupportLineName, OBJ_HLINE, 0, 0,iLow(NULL, 0, 0));
ObjectSet(SupportLineName, OBJPROP_COLOR, SRLineClr);
ObjectSet(SupportLineName, OBJPROP_WIDTH, SRLineWidth);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete(ResistanceLineName);
ObjectDelete(SupportLineName);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
if(AlarmOn){
double PreviousClosePrice = Bid;
if(SignalOnClose == true){PreviousClosePrice = iClose(NULL, 0, 1);}
double ResistancePrice = ObjectGet(ResistanceLineName, OBJPROP_PRICE1);
double SupportPrice = ObjectGet(SupportLineName, OBJPROP_PRICE1);
if(PreviousClosePrice > ResistancePrice && ResistancePrice != 0)Alerts(1);
if(PreviousClosePrice < SupportPrice && SupportPrice != 0)Alerts(2);
}
//----ho ho ho!!!!
return(0);
}
//+------------------------------------------------------------------+
void Alerts(int Direction)
{
static datetime AlertLastTime = 0;
if(TimeCurrent() > AlertLastTime ) {
AlertLastTime = TimeCurrent()+DelayBetweenAlarm;
PlaySound(SoundFile);
}
}
Comments