Author: Kalenzo
SSL_v2

This tool is designed as a visual aid for traders to help identify current market trends and potential support or resistance levels. It operates by analyzing the relationship between the current price and historical moving averages of high and low prices.

How the Logic Works

The script scans the market data by comparing the closing price of a candle against two specific types of "average" lines: one based on the highest prices reached and one based on the lowest prices reached over a set period (defined by the user as 10 periods by default).

Trend Detection: The tool functions like a state-tracker. It constantly checks whether the market is moving upward or downward:

  • Bullish Momentum: If the current price closes above the average of the previous highs, the script recognizes an upward trend.
  • Bearish Momentum: If the current price falls below the average of the previous lows, it recognizes a downward trend.

Visual Representation: Once the tool determines the direction of the market, it plots a dotted line on your chart to represent the "floor" or "ceiling" of the current price action:

  • When the market is trending downward, the indicator draws a line based on the average of the high prices.
  • When the market is trending upward, it shifts to draw a line based on the average of the low prices.

Summary for the User

Essentially, this script helps smooth out the "noise" of the market. Instead of looking at every tiny price fluctuation, it provides a continuous dotted line that adjusts based on whether the current momentum is positive or negative. It serves as a dynamic boundary, showing you where the trend's "base" sits in real-time.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SSL_v2
//+------------------------------------------------------------------+
//|                                                          SSL.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_buffers 1
#property indicator_chart_window
#property indicator_color1 CornflowerBlue
//----
extern int Lb=10;
double ssl[],Hld,Hlv;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,ssl);
   SetIndexStyle(0,DRAW_LINE,STYLE_DOT,1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   for(int i=Bars-Lb;i>=0;i--)
     {
      if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1))
         Hld=1;
      else
        {
         if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1))
            Hld=-1;
         else
            Hld=0;
        }
      if(Hld!=0)
         Hlv=Hld;
      if(Hlv==-1)
         ssl[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
      else
         ssl[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments