+dot
Download scriptThe SilverTrend Signal is a technical analysis tool designed to identify significant shifts in market momentum by monitoring price action behavior over a specific period. Instead of simply following every small fluctuation, this script filters out "market noise" to highlight when a trend is officially changing direction.
Core Logic and Mechanics
The indicator operates based on three primary analytical steps:
1. Volatility and Range Analysis The tool first calculates the average price range (the difference between the highest and lowest prices) over a set number of previous candles. By establishing this average, the script gains an understanding of how much the market typically moves in the current environment. This allows the signals to be scaled relative to the actual market volatility.
2. Dynamic Boundary Detection The script looks back at a specific window of price data to identify the highest highs and lowest lows reached during that time. Using these extremes, it establishes two dynamic "thresholds" (a ceiling and a floor). These boundaries are not fixed; they expand or contract based on a user-defined risk factor. The wider the volatility, the further apart these thresholds become.
3. Trend Confirmation Signals The indicator identifies a trend change by comparing the current closing price against these calculated thresholds:
- Bullish Shift: If the price closes above the upper threshold, the logic registers a potential move into an upward trend.
- Bearish Shift: If the price closes below the lower threshold, the logic registers a potential move into a downward trend.
Visual Output
The script is designed to provide clear, actionable visual cues on your chart:
- Trend Reversals: It triggers a signal only at the exact moment the trend state flips (e.g., moving from a bearish state to a bullish state).
- Dynamic Positioning: Rather than placing signals directly on the candle, it offsets them slightly above or below the price using the average range calculated in step one. This ensures that the signals are clearly visible and do not overlap with the actual price bars.
Summary for the Trader
Essentially, this tool acts as a "breakout detector." It ignores minor price movements and only alerts you when the price breaks through a significant boundary relative to recent history. When the trend flips, it places a visual marker on your chart, indicating a potential entry point or a shift in market sentiment.
//+------------------------------------------------------------------+
//| SilverTrend_Signal.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property copyright "SilverTrend rewritten by CrazyChart"
#property link "http://viac.ru/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Violet
//---- input parameters
extern int RISK=3;
extern int CountBars=350;
extern int SSP=9;
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| SilverTrend_Signal |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars+SSP);
SetIndexDrawBegin(1,Bars-CountBars+SSP);
int i,shift,counted_bars=IndicatorCounted();
int i1,i2,K;
double Range,AvgRange,smin,smax,SsMax,SsMin,price;
bool uptrend,old;
//----
if(Bars<=SSP+1) return(0);
//---- initial zero
if(counted_bars<SSP+1)
{
for(i=1;i<=SSP;i++) val1[CountBars-i]=0.0;
for(i=1;i<=SSP;i++) val2[CountBars-i]=0.0;
}
//----
K=33-RISK;
for (shift = CountBars-SSP; shift>=0; shift--)
{
Range=0;
AvgRange=0;
for (i1=shift; i1<=shift+SSP; i1++)
{AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
}
Range=AvgRange/(SSP+1);
SsMax=High[shift]; SsMin=Low[shift];
for (i2=shift;i2<=shift+SSP-1;i2++)
{
price=High[i2];
if(SsMax<price) SsMax=price;
price=Low[i2];
if(SsMin>=price) SsMin=price;
}
smin = SsMin+(SsMax-SsMin)*K/100;
smax = SsMax-(SsMax-SsMin)*K/100;
val1[shift]=0;
val2[shift]=0;
if (Close[shift]<smin)
{
uptrend = false;
}
if (Close[shift]>smax)
{
uptrend = true;
}
if (uptrend!=old && uptrend==true) {val1[shift]=Low[shift]-Range*0.5;}
if (uptrend!=old && uptrend==false) {val2[shift]=High[shift]+Range*0.5;}
old=uptrend;
}
return(0);
}
//+------------------------------------------------------------------+
Comments