SSL_channel_chart_varBLnSig_alert
Download scriptThis script is designed as a visual trend-following tool for trading platforms. Its primary purpose is to identify the direction of market momentum and provide clear visual cues on your chart to help distinguish between "bullish" (upward) and "bearish" (downward) price movements.
Core Logic and Trend Detection
The script operates by analyzing a moving average of the market's high and low prices over a specific period. Instead of simply looking at where the price is, it evaluates the relationship between the current closing price and these calculated averages:
- Trend Identification: The system continuously monitors whether the current price is trading above the "high" average or below the "low" average.
- Dynamic Shifting: When the price breaks through these specific thresholds, the script registers a shift in trend direction. It uses this logic to decide which side of the price action to highlight as the primary channel.
Visual Elements
To make this data easy to read at a glance, the script provides several visual components:
- The Channel Lines: The tool draws two boundary lines on your chart. These lines represent the "floor" and "ceiling" of the current market trend. When the trend is bullish, these lines adjust to reflect the relevant price boundaries; when it flips bearish, they recalibrate automatically to show the new boundaries.
- Directional Arrows: With the optional settings enabled, the script can place specific visual markers (arrows) on the chart at the exact moment a trend shift occurs. This allows you to see historical turning points clearly.
Smart Notifications
The script is equipped with a sophisticated alert system designed to keep you informed without constant manual monitoring. It features several layers of communication:
- Real-Time Alerts: You can choose to receive pop-up notifications on your screen, audio sounds, or even automated emails when the trend changes from up to down (or vice versa).
- Precision Timing: To prevent "noise" or false signals, the script includes an option to trigger these alerts only after a candle has fully closed. This ensures that a momentary price spike doesn't trigger an alert unless the trend shift is confirmed by the final price of the period.
In summary, this tool acts as a sophisticated filter that translates complex moving average data into a simplified visual "channel," alerting you whenever the market's fundamental momentum shifts direction.
//+------------------------------------------------------------------+
//| SSL channel chart.mq4 |
//| mladen |
//| |
//| initial SSL for metatrader developed by Kalenzo |
//+------------------------------------------------------------------+
//mod2009fxtsd +ln on/off
#property copyright "copyleft mladen"
#property link "mladenfx@gmail.com"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 OrangeRed
#property indicator_color4 Lime
#property indicator_width1 2
#property indicator_width2 2
//
//
//
//
//
extern int Lb = 10;
extern int sslMaMode = 0;
extern bool alertsOn = false;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;
extern bool alertsAfterBarClose = false;
extern bool showLines = true;
extern bool showArrows = false;
double ssld[];
double sslu[];
double sslad[];
double sslau[];
double Hlv[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int init()
{
IndicatorBuffers(5); if (showLines)int draw= DRAW_LINE; else draw= DRAW_NONE;
SetIndexBuffer(0,ssld); SetIndexDrawBegin(0,Lb+1); SetIndexStyle(0,draw);
SetIndexBuffer(1,sslu); SetIndexDrawBegin(0,Lb+1); SetIndexStyle(1,draw);
SetIndexBuffer(2,sslad); SetIndexDrawBegin(0,Lb+1); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,234);
SetIndexBuffer(3,sslau); SetIndexDrawBegin(0,Lb+1); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233);
SetIndexBuffer(4,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,sslMaMode,PRICE_HIGH,i+1)) Hlv[i] = 1;
if(Close[i]<iMA(Symbol(),0,Lb,0,sslMaMode,PRICE_LOW, i+1)) Hlv[i] = -1;
if(Hlv[i] == -1)
{
ssld[i] = iMA(Symbol(),0,Lb,0,sslMaMode,PRICE_HIGH,i+1);
sslu[i] = iMA(Symbol(),0,Lb,0,sslMaMode,PRICE_LOW ,i+1);
}
else
{
ssld[i] = iMA(Symbol(),0,Lb,0,sslMaMode,PRICE_LOW ,i+1);
sslu[i] = iMA(Symbol(),0,Lb,0,sslMaMode,PRICE_HIGH,i+1);
}
//
//
//
//
//
sslau[i] = EMPTY_VALUE;
sslad[i] = EMPTY_VALUE;
if (showArrows)
{
if (Hlv[i]!=Hlv[i+1])
if (Hlv[i]==1)
sslau[i] = ssld[i]-iATR(NULL,0,15,i)/2.0;
else sslad[i] = ssld[i]+iATR(NULL,0,15,i)/2.0;
}
}
//
//
//
//
//
if (alertsAfterBarClose)int b=1;else b=0;
if (alertsOn)
if (Hlv[0+b] != Hlv[1+b])
if (Hlv[0+b] == 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