SSL_channel_chartVar_alert

Download script
Author: mladen
SSL_channel_chartVar_alert

The SSL Channel indicator is designed to provide traders with a visual representation of current market trends by identifying the "flow" of price action. It functions by calculating dynamic support and resistance boundaries, which appear as two parallel lines on your trading chart.

How the Logic Works

Trend Identification The core logic relies on comparing the current closing price against moving averages derived from the high and low prices of previous candles. The script constantly evaluates whether the price is breaking above a certain threshold or falling below another. Based on this comparison, it assigns a specific "state" to the market:

  • Upward State: When the price shows strength by closing above the calculated upper resistance.
  • Downward State: When the price shows weakness by closing below the calculated lower support.

Dynamic Channel Formation The visual lines (the "channel") adapt automatically based on the market state identified above:

  • When the market is in an Upward State, the indicator positions its boundaries to highlight the prevailing momentum, shifting the visual focus to support the trend.
  • When the market shifts to a Downward State, the boundaries flip to reflect the new direction of the price action.

Visual and Audible Feedback The script is designed to act as an active monitoring tool. It constantly watches for "crossovers"—the exact moment the price flips from an upward trend to a downward trend, or vice versa. When such a shift occurs, the script can be configured to notify you instantly through several channels:

  • On-Screen Alerts: A pop-up message notifying you of the specific trend change and the current time.
  • Email Notifications: Sending a direct alert to your registered email provider.
  • Audio Signals: Playing a sound file to provide an immediate audible cue of the trend shift.

Key Features for Users

  • Customizable Smoothing: You can choose different moving average methods (such as Simple, Exponential, or Weighted) to change how "smooth" or "reactive" the lines appear.
  • Shift Settings: The script includes a slight "Bar Shift" to ensure that the lines are rendered with enough clearance to avoid visual clutter on the most recent candle.
  • Real-Time Monitoring: Because it calculates on every new price tick, it ensures that your chart stays updated with the most current market sentiment.
Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screenIt sends emailsIt plays sound alerts
12 Views
0 Downloads
0 Favorites
SSL_channel_chartVar_alert
//+------------------------------------------------------------------+
//|                                            SSL channel chart.mq4 |
//|                                                           mladen |
//|                                                                  |
//| initial SSL for metatrader developed by Kalenzo                  |
//+------------------------------------------------------------------+
//2008fxtsd mod variable ssl ma method

#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 int  sslMA_method  =  0;
extern int  BarShift      =  1;

extern bool alertsOn      = false;
extern bool alertsMessage = true;
extern bool alertsSound   = false;
extern bool alertsEmail   = false;
extern string  MA_method_ = "SMA0 EMA1 SMMA2 LWMA3";

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,sslMA_method,PRICE_HIGH,i+1)) Hlv[i] =  1;
         if(Close[i]<iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_LOW, i+1)) Hlv[i] = -1;
      
         if(Hlv[i] == -1)
            {
               ssld[i] = iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_HIGH,i+BarShift);
               sslu[i] = iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_LOW ,i+BarShift);
            }               
         else
            {
               ssld[i] = iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_LOW ,i+BarShift);
               sslu[i] = iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_HIGH,i+BarShift);
            } 
   }
   
   //
   //
   //
   //
   //
   
   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