SSL_channel_chartA

Download script
Author: mladen
SSL_channel_chartA

The SSL Channel is a visual trading tool designed to identify market trends and provide clear signals regarding price direction. It operates by analyzing the relationship between current market prices and historical averages to create a dynamic "channel" on your chart.

Core Logic and Functionality

Trend Identification The script works by constantly monitoring the closing price of a candle relative to two specific moving averages: one based on the recent high prices and another based on the recent low prices. It uses these two benchmarks to determine the prevailing market momentum. If the price consistently stays above certain thresholds, it identifies an upward trend; if it falls below others, it recognizes a downward shift.

The Dynamic Channel Based on the identified trend, the indicator draws a channel consisting of two lines:

  • In an Uptrend: The lines act as a framework showing the boundaries of the price movement, helping traders visualize the current "path" of the market.
  • In a Downtrend: The logic flips the calculation to reflect the new direction, ensuring the channel always adapts to the prevailing trend.

Smart Switching The script is designed to be reactive. It doesn't just draw lines statically; it switches its internal logic as soon as the price breaks through the established boundaries. This allows the visual channel to flip orientation automatically, signaling a transition from bullish to bearish behavior (or vice versa).

Automated Notifications To ensure traders don't have to watch the screen constantly, the script includes a comprehensive alert system. When the logic detects a formal trend reversal—meaning the market has officially shifted from one direction to another—it can provide immediate feedback through several channels:

  • On-Screen Alerts: A pop-up message notifying you of the specific trend change.
  • Audio Cues: An audible sound to grab your attention.
  • Email Notifications: Sending a direct message to your registered email (if configured), ensuring you stay informed even when away from your desk.

Summary for the User

In simple terms, this tool acts as a "trend compass." It filters out market noise by creating a visual tunnel that follows the price. When the price breaks out of one side of the tunnel and settles into the other, the indicator reconfigures itself and alerts you, helping you stay aligned with the primary direction of the market.

Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screenIt sends emailsIt plays sound alerts
9 Views
0 Downloads
0 Favorites
SSL_channel_chartA
//+------------------------------------------------------------------+
//|                                            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