[i]SilverTrend_Ron_MT4_v02

Download script
Author: SilverTrend rewritten by CrazyChart
[i]SilverTrend_Ron_MT4_v02

This script is designed as a visual trading tool that identifies shifts in market momentum by analyzing price behavior over a specific period. Instead of showing constant lines, it places distinct arrows on your chart to signal when the market sentiment has transitioned from bearish to bullish, or vice versa.

How the Logic Works

The script operates by scanning historical price data to establish "boundaries" for what constitutes a trend. Here is the step-by-step breakdown of its internal logic:

1. Range Analysis The tool first looks at a set number of recent candles (defined by the SSP parameter) to calculate the average daily movement. This helps the script understand the current volatility of the market—essentially determining how much the price typically fluctuates in a given timeframe.

2. Dynamic Boundary Setting The script identifies the highest peak and the lowest valley within that same period. It then uses these points to create two dynamic "thresholds" (a ceiling and a floor). The distance between these thresholds is determined by a risk percentage, allowing the tool to distinguish between minor price fluctuations and significant trend changes.

3. Trend Detection The script continuously monitors whether the current price is breaking above the upper threshold or falling below the lower threshold:

  • If the price closes above the upper threshold, it registers an uptrend.
  • If the price closes below the lower threshold, it registers a downtrend.

The tool can be configured to look at either the "Closing" price of a candle or the "Opening" price to make these decisions, depending on your preferred trading style.

4. Signal Generation The primary goal of the script is to detect the exact moment the trend flips.

  • Bullish Signal: When the market switches from a downtrend to an uptrend, the script places an arrow below the candle.
  • Bearish Signal: When the market switches from an uptrend to a downtrend, the script places an arrow above the candle.

The distance of these arrows from the candles is automatically adjusted based on the "Range" calculated in step 1, ensuring that the signals remain clearly visible and organized regardless of how volatile the market is at any given moment.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
[i]SilverTrend_Ron_MT4_v02
//+------------------------------------------------------------------+
//| SilverTrend_Signal.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property copyright "SilverTrend  rewritten by CrazyChart"
#property link      "http://viac.ru/"
// mods my Ron Thompson April 2006
 
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Magenta
 
//---- input parameters
extern int RISK=3;
extern int CountBars=1500;
extern int SSP=9;
extern bool UseClose=true;
 
//---- buffers
double val1[];
double val2[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
   
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,val1);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,val2);
  }
  
//+------------------------------------------------------------------+
//| SilverTrend_Signal                                               |
//+------------------------------------------------------------------+
int start()
  {   
   
   int i, i1, shift;
   
   double Range,AvgRange,smin,smax,SsMax,SsMin;
   
   bool uptrend,old;
  
   for (shift=CountBars; shift>=0; shift--) 
     { 
      Range=0;
      AvgRange=0;
      
      // Calculate Hi/Lo average for last SSP periods
      for (i1=shift; i1<=shift+SSP; i1++)
        {
         AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
        }
      Range=AvgRange/(SSP+1);
 
      // find highest high and lowest low SSP periods back
      SsMax=High[Highest(Symbol(),0,MODE_HIGH,SSP,shift)];
      SsMin= Low[Lowest (Symbol(),0,MODE_LOW ,SSP,shift)];
 
      smin = (SsMin+(((SsMax-SsMin)*(33-RISK))/100));
      smax = (SsMax-(((SsMax-SsMin)*(33-RISK))/100));
   
      if(UseClose)
       {
        if (Close[shift]<smin) uptrend = false;
        if (Close[shift]>smax) uptrend = true;
       }
      else
       {
        if (Open[shift]<smin) uptrend = false;
        if (Open[shift]>smax) uptrend = true;
       }
   
      if (uptrend!=old && uptrend==true)
        {
         val1[shift]=Low[shift]-Range*1.2;
         val2[shift]=0;
        }

      if (uptrend!=old && uptrend==false) 
        {
         val1[shift]=0;
         val2[shift]=High[shift]+Range*1.2;
        }

      old=uptrend;
 
     }//for
  
  }//start
  

Comments