SSL_channel_chart_alert-CA
Download scriptThe SSL Channel is a technical analysis tool designed to help traders visualize market trends and identify potential structural shifts in price action. By analyzing the relationship between current price movements and historical averages, it creates a dynamic "channel" on your chart that reacts to the prevailing momentum of the market.
Core Logic and Functionality
The script operates by monitoring two primary data points: the highest price peaks and the lowest price valleys over a specific period (defined by the user as the look-back length). It uses these values to construct a dual-layered channel.
Trend Identification: The tool continuously evaluates whether the current closing price is interacting with the high or low averages of the recent past.
- When the market shows bullish momentum, the logic identifies this state and adjusts the channel lines accordingly.
- When the market shifts to bearish momentum, the logic detects the crossover and flips the orientation of the channel.
Dynamic Channel Behavior: Unlike a static moving average, the SSL Channel is "reactive." It switches its boundary definitions based on the detected trend:
- In one trend state, the lines represent specific upper and lower boundaries that contract or expand based on volatility.
- When a trend reversal occurs, the script swaps the logic for these boundaries, effectively "flipping" the channel to align with the new direction of the market.
User Notifications and Alerts
To ensure traders can react to market changes in real-time without constantly staring at the screen, the script includes a comprehensive notification system.
The tool monitors for specific "trend flips"—the exact moment the logic switches from an upward bias to a downward bias (or vice versa). When this transition happens, the script can provide multiple types of feedback based on your preferences:
- Visual Alerts: A pop-up message window appears on the trading platform.
- Audio Cues: An audible sound signal plays to grab your attention.
- Email Notifications: An automated email is sent directly to your registered address, providing the specific time and symbol where the trend change occurred.
Practical Application
For a non-technical user, this means the indicator serves as a visual "guide rail." When the channel is oriented in one direction, it suggests a following trend; when the lines flip or cross, it signals a potential shift in market sentiment. It simplifies complex price data into a clear, readable visual cue that helps filter out market noise and highlight significant structural changes.
//+------------------------------------------------------------------+
//| 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 Yellow//LimeGreen
#property indicator_width1 2
#property indicator_width2 2
//----
extern int Lb =15;//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]>iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_HIGH,0,i+1)) Hlv[i]= 1;//iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_HIGH,i+1)) Hlv[i]= 1;
if(Close[i]<iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_LOW,0,i+1)) Hlv[i]= -1;//iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW,i+1)) Hlv[i]=-1;
if(Hlv[i]==-1)
{
ssld[i]=iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_HIGH,0,i+1);//iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_HIGH,i+1);
sslu[i]=iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_LOW,0,i+1);//iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW ,i+1);
}
else
{
ssld[i]=iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_LOW,0,i+1);//iMA(Symbol(),0,Lb,0,MODE_EMA,PRICE_LOW ,i+1);
sslu[i]=iCustom(NULL,0,"ma_i-CA",Lb,MODE_EMA,PRICE_HIGH,0,i+1);//iMA(Symbol(),0,Lb,0,MODE_EMA,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