SSL_channel_chart_LnSig_alert

Download script
Author: copyleft mladen
SSL_channel_chart_LnSig_alert

This tool is designed to help traders visualize market trends and identify potential shifts in price momentum by creating a dynamic "channel" on their trading charts. Rather than just showing a single line, it provides a visual boundary that reacts to the underlying price action.

Core Logic and Functionality

Trend Detection The script works by analyzing the relationship between the current market price and two moving averages: one based on the highest prices (highs) and one based on the lowest prices (lows) over a specific period. By comparing where the price sits relative to these averages, the tool determines the prevailing "sentiment" of the market—whether it is leaning toward an upward trend or a downward trend.

Dynamic Channel Formation The most distinct feature of this script is how it draws its lines:

  • In an Uptrend: The indicator adjusts its boundaries to reflect the current price flow, typically highlighting the range between the recent lows and highs.
  • In a Downtrend: The logic flips, reorganizing the boundaries to mirror the downward pressure.
  • This "flipping" behavior allows the channel to remain relevant regardless of which direction the market is moving, providing a clear visual corridor for price action.

Visual Signals Beyond the lines themselves, the script includes specific features to help with active trading:

  • Trend Visuals: Depending on your settings, it can display colored lines that represent the "walls" of the current trend.
  • Breakout Markers: The logic is capable of identifying the exact moment the trend switches (e.g., when the market moves from a "bullish" state to a "bearish" state). When this happens, the script can place visual markers (arrows) on the chart to alert you to the change.

Automated Notifications To ensure traders don't have to stare at the screen constantly, the script includes a notification system. It monitors for those specific trend reversals in real-time. When the market sentiment shifts, the tool can trigger several types of alerts simultaneously:

  • On-Screen Pop-ups: Immediate visual warnings on your platform.
  • Audio Alerts: Sound notifications to grab your attention instantly.
  • Email Notifications: Remote alerts sent directly to your inbox for when you are away from your terminal.

By combining these elements, the script serves as an automated trend-following assistant, providing a clear visual "map" of where the market is heading and alerting you the moment that direction changes.

Indicators Used
Moving average indicatorIndicator of the average true range
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt sends emailsIt plays sound alerts
11 Views
0 Downloads
0 Favorites
SSL_channel_chart_LnSig_alert
//+------------------------------------------------------------------+
//|                                            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 bool alertsOn      = false;
extern bool alertsMessage = true;
extern bool alertsSound   = false;
extern bool alertsEmail   = 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,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);
            } 

      //
      //
      //
      //
      //
      
      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 (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