JC - Line Break Alert1
Download scriptOverview
The JC - Line Break Alert is a specialized trading tool designed to monitor live market prices and notify you immediately when the price crosses or breaks through specific price levels. It acts as an automated watchman, allowing you to stay informed about key technical zones without having to stare at your screen constantly.
Key Functionalities
The script offers two primary ways to monitor the market depending on your trading strategy:
- Line Mode (Single Level): This mode focuses on one specific price point. It triggers an alert whenever the market price moves from below to above, or above to below, that designated line.
- Channel Mode (Dual Levels): This mode monitors a range between two different prices (a "channel"). It is designed to detect breakouts in either direction: it alerts you if the price breaks out above the upper boundary or falls below the lower boundary.
Smart Monitoring Features
To ensure the tool is as user-friendly as possible, it includes several intelligent behaviors:
- Interactive Price Adjustment: You can interact with the lines directly on your chart. If you manually move the price lines to different levels, the script automatically detects these changes and updates its monitoring logic to match your new settings.
- Smart Ordering: In Channel Mode, the script is designed to keep the boundaries organized. If it detects that the lines have been swapped (e.g., the lower bound is higher than the upper bound), it will automatically correct them to maintain a logical "floor" and "ceiling."
- One-Time Alert Logic: To prevent your workspace from being flooded with repetitive notifications, the script can be configured to deactivate itself once an alert has been triggered. This ensures you receive a single, clear notification for each breakthrough event.
Notification Options
Once a price breakout or crossing is detected, you can customize how you receive the information through multiple channels:
- Audio Alerts: Play a specific sound file a designated number of times to grab your attention instantly.
- Pop-up Notifications: Display an on-screen alert window showing the specific currency pair, timeframe, and the price at which the break occurred.
- Email Notifications: Optionally send a detailed email summary directly to your registered inbox, notifying you of the breakout even if you are away from your trading terminal.
Summary for Traders
This tool is built for precision. Whether you are looking for a simple "touch" alert on a major resistance level or monitoring a significant price corridor for a trend reversal, this script provides a reliable, automated way to receive real-time data updates with minimal manual intervention.
//+------------------------------------------------------------------+
//| JC - Line Break Alert.mq4 |
//| Juan Carlos Christensen. |
//| http://www.eumefinancial.com |
//+------------------------------------------------------------------+
#property copyright "Juan Carlos Christensen."
#property link "http://www.eumefinancial.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_width1 2
//---- input parameters
extern double Price1 = 2.0000;
extern double Price2 = 2.0000;
extern string Modes = "0- Line; 1- Channel";
extern int Mode = 1;
extern bool UseSoundAlert = True;
extern string SoundFile = "alert.wav";
extern int PlaySoundNTimes = 1;
extern bool UseAlertPopUp = True;
extern bool UseTickMode = True;
extern bool UseSendMail = False;
extern bool DeactivateOnAlert = True;
extern color price1_color = Blue;
extern color price2_color = Red;
bool DidBreakout = False;
double LastPrice;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
LastPrice=Bid;
CreateLine("price1",price1_color,Price1);
if(Mode==1) CreateLine("price2",price2_color,Price2);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("price1");
ObjectDelete("price2");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
double aPrice1=ObjectGet("price1",OBJPROP_PRICE1);
if(GetLastError()==4202) CreateLine("price1",price1_color,Price1);
if(aPrice1!=0 && aPrice1 != Price1) {Price1=aPrice1; Print("Price1 Changed:",Price1);}
if(Mode==1)
{
double aPrice2=ObjectGet("price2",OBJPROP_PRICE1);
if(GetLastError()==4202) CreateLine("price2",price2_color,Price2);
if(aPrice2!=0 && aPrice2 != Price2) {Price2=aPrice2; Print("Price2 Changed:",Price2);}
}
if(Price1<Price2 && Mode==1)
{
aPrice1=Price1;
Price1=Price2;
Price2=aPrice1;
ObjectSet("price1",OBJPROP_PRICE1,Price1);
ObjectSet("price2",OBJPROP_PRICE1,Price2);
}
switch(Mode)
{
case 0:
CrossingPrice1Only();
break;
case 1:
ChannelBreakOut();
break;
default:
CrossingPrice1Only();
}
//----
return(0);
}
//+------------------------------------------------------------------+
void CrossingPrice1Only()
{
double CurrentPrice=Bid;
if(((LastPrice < Price1) && (CurrentPrice >= Price1)) || ((LastPrice > Price1) && (CurrentPrice <= Price1)) && !DidBreakout)
{
if(DeactivateOnAlert) DidBreakout = True;
if(UseSoundAlert)
for(int x=0;x<=PlaySoundNTimes;x++)
PlaySound(SoundFile);
if(UseAlertPopUp)
Alert(Symbol()," ",Period(),"Price Crossing Alert Line at ", Price1); //Symbol()," ",Period()," @ ",Bid
if(UseSendMail)
SendMail("Price Crossing Alert Line at " + Price1 + "!", "This is an email from the JC - Line Break Alert indicator. Price is crossing your alert line at " + Price1 + "!");
}
}
//+------------------------------------------------------------------+
void ChannelBreakOut()
{
double CurrentPrice=Bid;
if((LastPrice < Price1) && (CurrentPrice >= Price1) && !DidBreakout)
{
if(DeactivateOnAlert) DidBreakout = True;
if(UseSoundAlert)
for(int x=0;x<=PlaySoundNTimes;x++) PlaySound(SoundFile);
if(UseAlertPopUp)
Alert(Symbol()," ",Period(),"Price Breaking Up at ", Price1);
if(UseSendMail)
SendMail("Channel Breaking Up at " + Price1 + "!", "This is an email from the JC - Line Break Alert indicator. Price broke up your channel alert line at " + Price1 + "!");
}
if((LastPrice > Price2) && (CurrentPrice <= Price2) && !DidBreakout)
{
if(DeactivateOnAlert) DidBreakout = True;
if(UseSoundAlert)
for(x=0;x<=PlaySoundNTimes;x++)
PlaySound(SoundFile);
if(UseAlertPopUp)
Alert(Symbol()," ",Period(),"Price Breaking Down at ", Price2);
if(UseSendMail)
SendMail("Channel Breaking Down at " + Price2 + "!", "This is an email from the JC - Line Break Alert indicator. Price broke down your channel alert line at " + Price2 + "!");
}
}
//+------------------------------------------------------------------+
void CreateLine(string aName, color aColor, double aPrice)
{
ObjectCreate(aName, OBJ_HLINE, 0, Time[0],aPrice);
ObjectSet(aName, OBJPROP_COLOR, aColor);
ObjectSet(aName, OBJPROP_STYLE, STYLE_DASH);
}
Comments