ForexOFFTrend(23SEP05)

Download script
Author: SilverTrend rewritten by CrazyChart
ForexOFFTrend(23SEP05)

How the SilverTrend Indicator Works

The SilverTrend script is a technical analysis tool designed to help traders identify potential trends and momentum shifts in the financial markets. Instead of relying on standard moving averages, it uses a logic based on price extremes—specifically looking at the highest highs and lowest lows over a specific period.

Here is a breakdown of how the logic functions:

1. Data Scope and Analysis Window

The indicator looks at a set number of historical bars (the "CountBars" parameter). Within this timeframe, it focuses on a smaller moving window (defined by the "SSP" parameter) to determine recent market behavior. This allows the script to react to current price action while maintaining a perspective on recent history.

2. Identifying Price Extremes

For every point in time, the script scans the market to find two key values:

  • The Highest High: The peak price reached within the moving window.
  • The Lowest Low: The bottom price reached within that same window.

By identifying these two points, the script calculates the "volatility range"—the total distance between the highest and lowest prices.

3. Dynamic Threshold Calculation

Once the high and low are identified, the script applies a percentage-based calculation (using the "Kmin" and "Kmax" parameters). It treats these percentages as "boundaries."

  • It calculates a specific price point based on how far the current price is from the recent extremes.
  • Essentially, it creates a mathematical "ceiling" and "floor" that shift dynamically as the market moves.

4. Trend Detection (Buy vs. Sell)

The core logic relies on comparing two different calculation paths (represented by the Red and Blue lines). The indicator monitors how these calculations interact with each other:

  • Buying Signal: If the primary calculation value rises above the secondary value, the script interprets this as upward momentum. It will display a "buy" comment on your chart.
  • Selling Signal: If the primary calculation value falls below the secondary value, the script interprets this as downward momentum. It will display a "sell" comment on your chart.

Summary for the Trader

In plain English, the SilverTrend indicator measures how far the price has stretched relative to its recent highs and lows. By comparing these two calculated paths, it attempts to filter out market "noise" and highlight the prevailing direction of the trend. When the lines cross or shift their relationship, it signals a change in momentum, providing a visual cue for whether the market is leaning toward a buying or selling bias.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
ForexOFFTrend(23SEP05)
//+------------------------------------------------------------------+
//|                                                 SilverTrend .mq4 |
//|                             SilverTrend  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 Red
#property indicator_color2 Blue
//---- input parameters

extern int       CountBars=300;
extern int       SSP=7;
extern double    Kmin=1.6;
extern double    Kmax=50.6; //24 21.6 21.6 


//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_LINE,0,2,Red);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,0,2,Blue);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
  if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+SSP);
   SetIndexDrawBegin(1,Bars-CountBars+SSP);
  int i, i2,loopbegin,counted_bars=IndicatorCounted();
  double SsMax, SsMin, K, val1, val2, smin, smax, price; 
  
  if(Bars<=SSP+1) return(0);
  //---- initial zero

//K=33-RISK; 

/*
if (firstTime==true)   { 
   loopbegin = CountBars; 
   if (loopbegin>(Bars-2*SSP+1)) loopbegin=Bars-2*SSP+1; 
   firstTime=False; 
}; ðóäèìåíò ñòàðîé ïðîãðàììû 
*/
  if(Bars<=SSP+1) return(0);
//---- initial zero

//+++++++
if(counted_bars<SSP+1)
   {
      for(i=1;i<=SSP;i++) ExtMapBuffer1[CountBars-i]=0.0;
      for(i=1;i<=SSP;i++) ExtMapBuffer2[CountBars-i]=0.0;
   }
//+++++++-SSP


for(i=CountBars-SSP;i>=0;i--) { 


  SsMax = High[Highest(NULL,0,MODE_HIGH,SSP,i-SSP+1)]; 
  SsMin = Low[Lowest(NULL,0,MODE_LOW,SSP,i-SSP+1)]; 
   smin = SsMin-(SsMax-SsMin)*Kmin/100; 
   smax = SsMax-(SsMax-SsMin)*Kmax/100;  
   ExtMapBuffer1[i-SSP+6]=smax; 
   ExtMapBuffer2[i-SSP-1]=smax; 
   val1 = ExtMapBuffer1[0]; 
   val2 = ExtMapBuffer2[0]; 
if (val1 > val2) Comment("ïîêóïêà buy ",val1); 

if (val1 < val2) Comment("ïðîäàæà sell ",val2); 

 
}
  

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

Comments