SilverTrend With Alert

Author: SilverTrend rewritten by CrazyChart
SilverTrend With Alert

The SilverTrend Signal is a technical analysis tool designed to identify potential trend reversals in the market by monitoring price action relative to recent historical extremes. Rather than just looking at individual price movements, this script analyzes a rolling window of data to determine when the market's momentum is shifting from one direction to another.

How the Logic Works

The script functions by performing three primary calculations for every candle on your chart:

1. Volatility and Range Assessment The tool first calculates the average "range" (the distance between the highest and lowest price) over a specific period of recent candles. This helps the script understand the current market's volatility, ensuring that its signals are scaled appropriately to the current environment—meaning it adjusts its sensitivity whether the market is moving slowly or swinging wildly.

2. Extreme Boundary Detection The script identifies the highest highs and lowest lows reached during a specific look-back period. It then establishes two dynamic "threshold" levels based on these extremes:

  • The Upper Threshold: A level slightly below the recent peak.
  • The Lower Threshold: A level slightly above the recent trough.

These boundaries are calculated using a user-defined risk percentage, which determines how much "room" is given to the price before a trend change is confirmed.

3. Trend Confirmation and Alerts The core logic triggers a signal based on where the current closing price lands in relation to these thresholds:

  • Buy Signals: If the price closes above the established upper threshold, the script identifies an "Uptrend" shift. It then places a visual indicator on the chart and, if configured, sends an automated alert for a potential Buy opportunity.
  • Sell Signals: If the price drops below the lower threshold, the script identifies a "Downtrend" shift. It marks the chart with a visual cue and triggers an alert for a potential Sell opportunity.

Summary of User Experience

For a trader, this means the tool filters out minor market "noise" by requiring the price to break past significant recent highs or lows before signaling a change. When a trend flip occurs, the script provides immediate visual markers on the chart and proactive notifications (alerts), allowing for quicker reactions to market shifts without having to constantly monitor every price tick manually.

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
SilverTrend With Alert
//+------------------------------------------------------------------+
//| 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 NumberofAlerts=2;
int SSP=9;
int counter=0;
//---- 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;
   counter=0;
   if (shift==0 && counter<=NumberofAlerts) 
   {
   Alert(Symbol()," - ",Period(),"  ","Silver Trend"," ","BUY","  ",Bid); 
   counter=counter+1;
   }
   }
   if (uptrend!=old && uptrend==false) 
   {
   counter=0;
   val2[shift]=High[shift]+Range*0.5;
   if (shift==0 && counter<=NumberofAlerts) 
   {
   Alert(Symbol()," - ",Period(),"  ","Silver Trend"," ","SELL","  ",Ask);
   counter=counter+1;
   
   }
   }
   Comment(shift);
   old=uptrend;

}
   return(0);
  }
//+------------------------------------------------------------------+

Comments