SSL_fast
Download scriptThis custom indicator is designed to provide visual clarity on a trading chart by identifying specific price trends and shifting levels based on historical price action. Instead of simply showing a standard moving average, it acts as a dynamic "Smart Line" that reacts to the direction of the market.
Core Logic Overview
The script functions by constantly monitoring the relationship between the current closing price and the high/low boundaries of the recent past. It uses a smoothing period (defined by a user-adjustable setting) to filter out minor market noise, ensuring that the line reflects a broader trend rather than every small fluctuation.
How it Determines Direction
The indicator operates using a "memory" system to determine the current market sentiment:
- Trend Detection: The script looks at whether the price has closed above or below specific moving averages based on previous highs and lows.
- State Switching: If the price breaks above a certain threshold, the logic registers a positive trend. If it drops below a different threshold, it registers a negative trend.
- Dynamic Level Selection: This is the most unique part of the script. Instead of staying on one fixed calculation, the line "switches" its source. When the market is trending downward, the indicator calculates its position based on high price points; when the market trends upward, it switches to calculating based on low price points.
Visual Result
For a trader viewing the chart, this results in a dotted blue line that behaves intelligently. Rather than cutting straight through the middle of price candles, the line adapts to the "outer edges" of the price action. It attempts to stay out of the way of the primary price movement while providing a clear visual cue of where the trend boundary currently sits. By switching its calculation method based on momentum, it provides a more responsive view of support and resistance levels than a traditional fixed indicator.
//+------------------------------------------------------------------+
//| SSL.mq4 |
//| ssl fast Kalenzo |
//| bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
//mod2008forextsdml
#property copyright "Kalenzo"
#property link "bartlomiej.gorski@gmail.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 CornflowerBlue
#property indicator_style1 STYLE_DOT
extern int Lb = 10;
double ssl[];
double Hlv[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexBuffer(0,ssl); SetIndexDrawBegin(0,Lb+1);
SetIndexBuffer(1,Hlv);
return(0);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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)
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