SilverTrendSignal_v1

Download script
Author: SilverTrend rewritten by CrazyChart
SilverTrendSignal_v1

This technical script functions as a visual trend-following tool designed to identify specific price action reversals by monitoring market extremes and volatility. It analyzes historical price data to pinpoint moments where the market moves significantly outside of established "normal" boundaries.

Core Operational Logic

1. Boundary Definition (Dynamic Envelopes) The tool first establishes a "zone of interest" by looking at a set period of recent history (defined by the SSP parameter). It identifies the highest price and the lowest price reached during this window. Based on these extremes, it calculates two dynamic thresholds:

  • A Lower Boundary: A specific percentage below the peak.
  • An Upper Boundary: A specific percentage above the valley.

The width of these boundaries is influenced by a "Risk" setting, which determines how aggressively or conservatively the tool interprets price deviations.

2. Volatility Measurement To ensure the signals are relevant to current market conditions, the script calculates the average range (the difference between the high and low) of recent price bars. This allows the indicator to understand the "breath" of the market—whether it is moving in small, stable increments or experiencing large, volatile swings.

3. Signal Detection (The Reversal Logic) The tool constantly compares the current closing price against the calculated boundaries:

  • Bearish Identification: If the price closes below the lower boundary, the script searches backward through recent history to see if there was a previous "buy" signal that hasn't been neutralized. If it finds this specific sequence, it generates a visual signal at the top of the current bar.
  • Bullish Identification: Conversely, if the price closes above the upper boundary, the script looks back to see if a "sell" signal was previously active. If confirmed, it generates a visual signal at the bottom of the current bar.

4. Smoothing and Visual Presentation The logic includes a memory mechanism that tracks previous states to ensure signals appear in a logical sequence. By calculating these points dynamically based on both price distance and historical volatility, the script aims to highlight moments where a trend is likely exhausting itself and preparing for a reversal.

Summary for the User

Essentially, this tool acts as an "oversold/overbought" detector that adapts to the market's personality. Instead of giving signals every time the price moves slightly, it waits for the price to push into extreme territory (the boundaries) while simultaneously verifying that the previous trend has reached a point of structural exhaustion.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SilverTrendSignal_v1
//+------------------------------------------------------------------+
//|                                                 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