SSL_channel_chart_alert
Download scriptTechnical Overview: SSL Channel Indicator
The SSL Channel is a visual trend-analysis tool designed to help traders identify price momentum and potential reversal points on a trading chart. By calculating the relationship between current market prices and historical averages, it provides a dynamic "channel" that shifts based on whether the market is trending upward or downward.
Core Logic and Functionality
The script operates by monitoring three primary components of market data to determine the trend:
- Trend Detection: The system looks at the relationship between the current closing price and two specific moving averages: one based on the highest prices over a set period, and another based on the lowest prices.
- Dynamic Channel Switching: Depending on whether the market is currently "breaking out" above the high average or "dropping below" the low average, the script flips its logic. When the trend is bullish, it draws the channel based on one set of price boundaries; when the trend turns bearish, it automatically swaps those boundaries to reflect the new direction.
- Visual Feedback: On your chart, this manifests as two distinct lines (colored Red and Green) that form a corridor or "channel." This corridor acts as a visual guide for the current market structure.
Automated Alerts
Beyond just drawing on the chart, the script includes an integrated notification system designed to keep traders informed of structural changes in real-time:
- Trend Change Detection: The logic constantly monitors for the exact moment the trend flips (e.g., switching from a bullish state to a bearish state).
- Customizable Notifications: When a trend change is detected, the script can be configured to notify you through multiple channels:
- On-Screen Pop-ups: Immediate visual alerts within the trading platform.
- Email Notifications: Sending a summary of the trend change directly to your inbox.
- Audio Alerts: Triggering a specific sound file to provide an audible signal during live market sessions.
Summary for Users
Essentially, this tool simplifies market noise by highlighting the prevailing trend. Instead of manually guessing where the price "should" be, it draws a corridor around the current price action. When the price breaks through the boundaries of this corridor in a significant way, the script updates its logic and alerts you, allowing for faster identification of potential trade entries and exits.
//+------------------------------------------------------------------+
//| SSL channel chart.mq4 |
//| mladen |
//| |
//| initial SSL for metatrader developed by Kalenzo |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 2
#property indicator_width2 2
//----
extern int Lb =10;
extern bool alertsOn =false;
extern bool alertsMessage=true;
extern bool alertsSound =false;
extern bool alertsEmail =false;
//----
double ssld[];
double sslu[];
double Hlv[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0,ssld); SetIndexDrawBegin(0,Lb+1);
SetIndexBuffer(1,sslu); SetIndexDrawBegin(0,Lb+1);
SetIndexBuffer(2,Hlv);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
//----
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//----
for(i=limit;i>=0;i--)
{
Hlv[i]=Hlv[i+1];
if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1)) Hlv[i]= 1;
if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1)) Hlv[i]=-1;
if(Hlv[i]==-1)
{
ssld[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
sslu[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW ,i+1);
}
else
{
ssld[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW ,i+1);
sslu[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
}
}
//----
if (alertsOn)
if (Hlv[0]!=Hlv[1])
if (Hlv[0]==1)
doAlert("up");
else doAlert("down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void doAlert(string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
//----
if (previousAlert!=doWhat || previousTime!=Time[0])
{
previousAlert =doWhat;
previousTime =Time[0];
//----
message= StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," SSL trend changed to ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol(),"SSL "),message);
if (alertsSound) PlaySound("alert2.wav");
}
}
//+------------------------------------------------------------------+
Comments