SilverTrend_Signal_v1
Download scriptThis tool is designed to analyze market price movements and provide visual signals on your trading chart, helping identify potential shifts in trend direction. Instead of cluttering the screen with constant lines, it focuses on highlighting specific moments where the price momentum changes.
How the Logic Works
The script functions by examining a specific window of recent price history to determine whether the market is currently moving upward or downward. It performs this analysis through three main steps:
1. Measuring Market Volatility The tool first calculates the "Average Range" of the candles over a set period. By looking at the difference between the highest and lowest points of these candles, it establishes a sense of how much the price is swinging. This ensures that the signals it generates are scaled appropriately to the current market environment.
2. Identifying Dynamic Boundaries The script identifies the highest highs and lowest lows within its look-back period. It then calculates two dynamic "threshold" levels—a ceiling and a floor. These boundaries are not fixed; they move in relation to the recent price action.
3. Detecting Trend Transitions The core logic relies on comparing the current closing price against these dynamic thresholds:
- Trend Confirmation: If the price closes above the upper threshold, the tool recognizes an upward trend.
- Trend Reversal: If the price closes below the lower threshold, it recognizes a downward trend.
Visual Signals
The script is programmed to "remember" the previous trend state. When it detects a change—for example, moving from an upward trend to a downward trend—it places a visual arrow on the chart at the exact point of transition.
- Buy/Upward Signals: These appear when the price breaks through the upper boundary, indicating a shift toward bullish momentum.
- Sell/Downward Signals: These appear when the price breaks through the lower boundary, indicating a shift toward bearish momentum.
By filtering out minor fluctuations and only highlighting significant "breakouts" of these calculated boundaries, the tool aims to provide a clearer picture of the market's primary direction.
//+------------------------------------------------------------------+
//| 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,233);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
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