SHI_SilverTrendSig_v4

Download script
Author: Copyright � 2005, Shurka
SHI_SilverTrendSig_v4

The SHI_SilverTrendSig is a technical analysis tool designed for the MetaTrader platform to help traders identify potential trend reversals by highlighting specific price action patterns. Rather than relying on a single price point, this script analyzes the relationship between current price movement and historical extremes over a defined period.

Core Logic Overview

The indicator functions by scanning historical price data to determine if the market is reaching an "exhaustion" point—a state where the price has moved significantly far from its recent average and is beginning to react against that momentum. It achieves this through three main logical components:

1. Range and Volatility Analysis The script calculates a weighted value based on the difference between the high and low prices of previous bars. By giving more importance to recent price action, it creates a customized measure of current market volatility. This helps the indicator distinguish between steady, healthy trends and erratic, overextended movements.

2. Peak and Trough Identification The tool looks back at a specific number of candles (defined by the user) to find the highest high and the lowest low within that window. By identifying these boundaries, the script establishes a "trading zone." It then calculates a percentage-based threshold (the "Step back") to determine how close the current price is to these extremes.

3. Trend Reversal Signals The primary logic triggers a visual signal based on two conditions:

  • Sell Signal: If the current closing price drops below a specific percentage of the recent high/low range, and the previous status was not already a "Sell," it identifies a potential downward shift.
  • Buy Signal: If the current closing price rises above a specific percentage of the recent high/low range, and the previous status was not already a "Buy," it identifies a potential upward shift.

Visual Output

When these conditions are met, the script places visual arrows on your chart:

  • Blue Arrows typically appear below the price to indicate a "Buy" signal (identifying where the price has dropped enough to potentially bounce back up).
  • Red Arrows typically appear above the price to indicate a "Sell" signal (identifying where the price has risen enough to potentially pull back down).

Key Behavior Notes

  • State Memory: The indicator tracks its current state to ensure it doesn't clutter your chart with repetitive signals; it waits for a confirmed change in trend direction before highlighting a new signal.
  • Customizable Sensitivity: Users can adjust the "Period" (how far back the script looks) and the "Step Back" (how close to the extreme the price must be to trigger an arrow), allowing the tool to be tuned for different types of markets or faster/slower trading styles.
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SHI_SilverTrendSig_v4
//+------------------------------------------------------------------+
//|                                           SHI_SilverTrendSig.mq4 |
//|          Copyright © 2003, VIAC.RU, OlegVS, GOODMAN, 2005 Shurka |
//|                                                 shforex@narod.ru |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Shurka"
#property link      "http://shforex.narod.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#define  SH_BUY   1
#define  SH_SELL  -1
//---- Âõîäíûå ïàðàìåòðû
extern int     AllBars=0;//How many bars should be counted. 0 - all the bars.
extern int     Otstup=30;//Step back.
extern double  Per=9;//Period.
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíèöèàëèçàöèè                                            |
//+------------------------------------------------------------------+
int init()
  {
   //We will write the number of the bars for which we are counting to the NB
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,BufU);
   SetIndexBuffer(1,BufD);
   SetIndexDrawBegin(0,Bars-NB);//This indicator will be shown for NB bar only
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);//Give a lot of "zero" to the buffe. Otherwise it will be garbage during the changing of time frame.
   ArrayInitialize(BufU,0.0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Ôóíêöèÿ äåèíèöèàëèçàöèè                                          |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Ñîáñíà èíäèêàòîð                                                 |
//+------------------------------------------------------------------+
int start()
  {
   int CB=IndicatorCounted();
   /* It is the optimization option. We have the function here which restore/return the number of counted bars in very special way. 
   During the first indicator's call we have 0: it is normal because it was not counted anything, 
   and then we receive the number of bars minus 1. For example, if the number of bars equal 100,
   we will have 99. I did it especially, you may see that NB is the number of bars whioch should be counted. 
   You know we may throw out this parameter. But for the people who understand we may keep it. So, during the first call
   of indicator this NB is the same one but during the 2dn etc calls - reducing the value up to the last bar, 
   That is 1 or 2 for example*/
   if(CB<0) return(-1); else if(NB>Bars-CB) NB=Bars-CB;
   for(SH=1;SH<NB;SH++)//comb out the chart from 1 to NB
     {
      for(R=0,i=SH;i<SH+10;i++) {R+=(10+SH-i)*(High[i]-Low[i]);}      R/=55;
//----
      SHMax=High[Highest(NULL,0,MODE_HIGH,Per,SH)];
      SHMin=Low[Lowest(NULL,0,MODE_LOW,Per,SH)];
      if (Close[SH]<SHMin+(SHMax-SHMin)*Otstup/100 && UD!=SH_SELL) { BufU[SH]=Low[SH]-R*0.5; UD=SH_SELL; }
      if (Close[SH]>SHMax-(SHMax-SHMin)*Otstup/100 && UD!=SH_BUY) { BufD[SH]=High[SH]+R*0.5; UD=SH_BUY; }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments