[i]SilverTrend_Ron_MT4_v02_v1
Download scriptThis tool is designed to identify potential trend reversals in the financial markets by analyzing price action patterns over a specific period. Instead of just looking at individual price points, it evaluates the "strength" and "range" of price movements to determine when a market direction is likely shifting from bullish (upward) to bearish (downward), or vice versa.
Core Logic and Methodology
The script operates by scanning historical price data to establish a visual "boundary" for the market. Here is how it processes that information:
1. Establishing the Market Range The tool first calculates the average volatility of the market over a set number of recent bars. It looks at the difference between the highest and lowest prices during these periods to understand how much the price typically swings. This helps the script distinguish between normal market "noise" and significant movements.
2. Identifying Extremes (Support and Resistance) The logic identifies the highest high and the lowest low within a specific timeframe. Based on these extremes, it calculates two dynamic boundaries:
- A lower threshold (Support)
- An upper threshold (Resistance)
By using a "Risk" factor, the tool adjusts how far inside these extremes the boundaries are placed. This allows the script to be more or less sensitive to price changes depending on the user's preference for conservative or aggressive signaling.
3. Trend Detection The script monitors whether the current market price is breaking above the upper boundary or falling below the lower boundary. It tracks the "state" of the trend:
- If the price breaks above the upper limit, it recognizes an Uptrend.
- If the price breaks below the lower limit, it recognizes a Downtrend.
4. Signal Generation The actual visual signals on the chart are triggered only at the exact moment the trend state changes.
- When the market flips from a neutral or downward state into an Uptrend, a specific marker appears below the price candle.
- When the market flips from an upward state into a Downtrend, a corresponding marker appears above the price candle.
To ensure these signals are clearly visible, the tool places the markers at a set distance away from the price candles (based on the volatility calculated in step 1), preventing the indicators from overlapping with the actual trading data.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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