SilverTrendSignal

Download script
Author: SilverTrend rewritten by CrazyChart
SilverTrendSignal

The SilverTrend indicator is designed to analyze market price action by identifying specific structural boundaries and detecting shifts in momentum. Rather than relying on simple moving averages, it focuses on the relationship between recent price extremes and the current trading range to forecast potential trend reversals or continuations.

Core Logic Overview

1. Dynamic Range Analysis The script begins by calculating the average "range" of the market over a specific look-back period. By measuring the distance between the highs and lows of previous candles, it establishes a baseline for how much the price is currently fluctuating. This allows the indicator to scale its visual signals based on the volatility of the current environment.

2. Boundary Detection (Support and Resistance) The logic identifies key price levels by looking at the highest highs and lowest lows within a set window of time. It then calculates two specific "threshold" points:

  • An Upper Threshold: Derived from the recent high.
  • A Lower Threshold: Derived from the recent low.

These thresholds act as a "buffer zone." The indicator uses these levels to determine if the price is pushing aggressively outside of its normal trading boundaries or if it is entering a state of exhaustion.

3. Trend Shift Identification The script monitors whether the closing price has breached these established thresholds. It looks for specific sequences:

  • Downside Pressure: If the price drops below the lower threshold, the logic searches for a historical "buy" signal or a specific reversal point in the preceding data to confirm a potential shift. If confirmed, it plots a signal representing a proactive move.
  • Upside Pressure: Conversely, if the price climbs above the upper threshold, the script scans backward to see if there was a corresponding "sell" state. If the conditions are met, it generates a signal indicating a downward reversal or a correction.

4. Visual Representation The results of these calculations are displayed on the chart as two distinct colored sections (Fuchsia and Aqua). These lines do not just sit on the price; they appear dynamically when the logic detects that the market has moved far enough outside its "normal" range to suggest a significant trend change.

Summary for Traders

In simple terms, this script acts as a sophisticated "overextended" detector. It calculates where the price should be based on recent history and identifies moments where the price moves so far beyond those limits that a reversal or a significant trend shift becomes statistically noteworthy. It filters out minor market noise by requiring the price to break through specific calculated thresholds before highlighting a potential signal.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
SilverTrendSignal
//+------------------------------------------------------------------+
//|                                                 SilverTrend .mq4 |
//|                       SilverTrendSignal  rewritten by CrazyChart |
//|                                                 http://viac.ru/  |
//+------------------------------------------------------------------+
#property copyright "SilverTrend  rewritten by CrazyChart"
#property link      "http://viac.ru/ "

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Fuchsia
#property indicator_color2 Aqua
//---- input parameters
extern int       RISK=3;
extern int       CountBars=300;
extern int       SSP=9;
//---- buffers
double ExtSignal1[];
double ExtSignal2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,ExtSignal1);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(1,DRAW_SECTION);
   SetIndexBuffer(1,ExtSignal2);
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here

  bool firstTime=True;
  int i, loopbegin,i1,shift,cnt,deltaBar,deltaPrice,x;
  double SsMax, SsMin, K, val1, val2, smin, smax, Table_value2[500][4]; 
  double MyBars,value3,Range,AvgRange,SSP;
  double topHigh[2],downLow[2],changePrice;
  



K=33-RISK; 
if (firstTime==true)   { 
   loopbegin = Bars-CountBars; 
   MyBars=loopbegin; 
   firstTime=False; 
} 

for (shift=Bars-SSP;shift>=0;shift--) { 
   Range=0; 
   AvgRange=0; 
   for (i1=shift;i1<=shift+9;i1++) {
      AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]); 
   } 
   Range=AvgRange/10; 
   
   SsMax = High[Highest(MODE_HIGH,shift+SSP-1,SSP)]; 
   SsMin = Low[Lowest(MODE_LOW,shift+SSP-1,SSP)]; 
   smin = SsMin+(SsMax-SsMin)*K/100; 
   smax = SsMax-(SsMax-SsMin)*K/100; 
   Table_value2[shift][1]=shift; 
   Table_value2[shift][2]=Close[shift]; 
   Table_value2[shift][3]=0; 
   ExtSignal1[shift]=0;//ExtSignal1[shift+1]; 
   ExtSignal2[shift]=0;//ExtSignal2[shift+1]; 
   value3=0;
   
   if (Close[shift]<smin) {
      i1=1; 
      Table_value2[shift][3]=-1; 
      while (Table_value2[shift+i1][3]>-1 && Table_value2[shift+i1][3]<1 && Table_value2[shift+i1][2]>0) {
         i1=i1+1;
      } 
      if (Table_value2[shift+i1][3]==1) { 
         value3=High[shift]+Range*0.5; 
         ExtSignal1[shift]=value3;
      
       
      } 
   } 

   if (Close[shift]>smax) {
      i1=1; 
      Table_value2[shift][3]=1; 
         while (Table_value2[shift+i1][3]>-1 && Table_value2[shift+i1][3]<1 && Table_value2[shift+i1][2]>0) {
            i1=i1+1;
         } 
         if (Table_value2[shift+i1][3]==-1) {
             value3=Low[shift]-Range*0.5; 
            ExtSignal2[shift]=value3; 
         } 
   } 
   
 
   if (shift>0) loopbegin=loopbegin+1; 
   if (MyBars<Bars && shift==0) { 
      for (i1=72;i1==2;i1--) {
         Table_value2[i1][1]=Table_value2[i1-1][1]; 
         Table_value2[i1][2]=Table_value2[i1-1][2]; 
         Table_value2[i1][3]=Table_value2[i1-1][3]; 
      } 
   MyBars=MyBars+1; 
   } 





 
}
  

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

Comments