SilverBank 01
Download scriptThis trading indicator is designed to identify significant shifts in market momentum by analyzing price action over a specific historical window. It functions by scanning the recent price movement to determine "breakout" zones, helping traders visualize when the trend might be transitioning from one direction to another.
Core Logic and Mechanics
Dynamic Range Analysis The script begins by calculating the volatility of the market. It looks at a predefined number of previous bars (the lookback period) to establish the average range—essentially measuring how much the price typically fluctuates between its highs and lows. This ensures that the indicator adapts to different market conditions, whether the market is moving calmly or experiencing high-intensity swings.
Defining Thresholds To filter out "noise" and focus on significant moves, the logic establishes two key boundaries based on the highest high and lowest low within its lookback period:
- Upper Boundary: A calculated ceiling used to identify strong upward momentum.
- Lower Boundary: A calculated floor used to identify strong downward momentum.
These boundaries are not fixed; they are weighted percentages of the total price range, allowing the indicator to react proportionally to how much the market is moving at any given moment.
Trend Detection and Signals The primary purpose of the script is to detect "state changes" in the market trend:
- Bullish Shift: If the closing price moves above the upper boundary, the logic registers an upward trend.
- Bearish Shift: If the closing price falls below the lower boundary, the logic registers a downward trend.
When the script detects a change from a bearish state to a bullish one (or vice versa), it places visual markers on the chart. These markers are positioned relative to the current price and the calculated average range, providing a clear signal of where the momentum has flipped.
Visual Filtering To prevent the chart from becoming cluttered with repetitive signals, the script includes a "Delta" filter. This ensures that a new signal is only displayed if there is a significant enough gap between the previous trend levels. This helps traders focus on distinct price movements rather than minor fluctuations.
Summary for the User
In plain terms, this tool acts as a momentum scanner. It watches the market to see when the price breaks out of its recent "normal" behavior. When the price pushes significantly higher or lower than the established boundaries of the past few hours (or bars), the indicator highlights these shifts, helping you spot potential trend reversals or sustained breakouts in real-time.
//+------------------------------------------------------------------+
//| Filename changed to ForexOFFTrend.mq4 by CrazyChart & Lukas1 |
//| SilverBank .mq4 |
//| SilverBank changed by CrazyChart & Lukas1|
//| For 15 min & more long. idea from http://viac.ru/ |
//+------------------------------------------------------------------+
//àíãë. bank - ñóùåñòâèòåëüíîå: íàñûïü, îòêîñ; áåðåã; êðåí; áàíê; êîìïëåêò, íàáîð;
// âåðñòàê; ìåñòî õðàíåíèÿ çàïàñîâ; ðàçúåì äëÿ ïîäêëþ÷åíèÿ ïàìÿòè [êîìï.]
//
#property copyright "SilverTrend rewritten by CrazyChart"
#property link "http://viac.ru/ "
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 Violet
//---- input parameters
extern int CountBars = 5400;
extern int SSP = 21;
extern int Delta = 3;
extern double Kmin = 1.6;
extern double Kmax = 50.6;
extern bool gAlert = false; // Switch to allow alerts
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double Wal1[];
double Wal2[];
//----
bool gSellAlertGiven = false; // Used to stop constant alerts
bool gBuyAlertGiven = false; // Used to stop constant alerts
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(4);
SetIndexStyle(0, DRAW_LINE, 0, 2);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_LINE, 0, 2);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,233);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,234);
SetIndexBuffer(2,Wal1);
SetIndexBuffer(3,Wal2);
//----
if(CountBars >= Bars)
CountBars = Bars;
SetIndexDrawBegin(0, Bars - CountBars + SSP);
SetIndexDrawBegin(1, Bars - CountBars + SSP);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, i1, i2, shift, loopbegin, counted_bars = IndicatorCounted();
double SsMax, SsMin, K, val1, val2, smin, smax, price;
double Range, AvgRange;
bool uptrend,old;
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;
for(i = 1; i <= SSP; i++) Wal1[CountBars-i] = 0.0;
for(i = 1; i <= SSP; i++) Wal2[CountBars-i] = 0.0;
}
for(i = CountBars - SSP; i >= 0; i--) // ìåíÿåì çäåñü
{
Range=0;
AvgRange=0;
for (i1=shift; i1<=shift+SSP; i1++)
{AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);}
Range=AvgRange/(SSP+1);
SsMax = High[Highest(NULL, 0, MODE_HIGH, SSP, i - SSP + 1)];
SsMin = Low[Lowest( NULL, 0, MODE_LOW, SSP, i - SSP + 1)];
for (i2=shift;i2<=shift+SSP-1;i2++)
{
price=High[i2];
price=Low[i2];
}
smin = NormalizeDouble((SsMin - (SsMax - SsMin)*Kmin / 100), 6);
smax = NormalizeDouble((SsMax - (SsMax - SsMin)*Kmax / 100), 6);
ExtMapBuffer1[i-SSP+6] = smax;
ExtMapBuffer2[i-SSP-1] = smax;
val1 = ExtMapBuffer1[i-1];
val2 = ExtMapBuffer2[i-1];
Wal1[shift]=0;
Wal2[shift]=0;
if (Close[shift]<smin)
{
uptrend = false;
}
if (Close[shift]>smax)
{
uptrend = true;
}
if (uptrend!=old && uptrend==true) {Wal1[shift]=Low[shift]-Range*0.5;}
if (uptrend!=old && uptrend==false) {Wal2[shift]=High[shift]+Range*0.5;}
old=uptrend;
if(val1 > val2+Delta*Point)
{
Wal1[i]=val1;
}
if(val1 < val2-Delta*Point)
{
Wal2[i]=val2;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments