Volatility.Pivot_002
Download scriptThis script is designed to act as a dynamic volatility tracker for financial charts. Its primary purpose is to identify and visualize significant price boundaries, helping traders understand the "swing" range of the market based on current activity levels.
Core Logic Overview
The tool operates by calculating a shifting baseline that reacts to how much the market is moving at any given moment. Instead of using fixed numbers, it adapts to the market's personality—expanding when the market is volatile and tightening when the market becomes quiet.
How It Works
1. Measuring Market Movement (Volatility) The script first analyzes a specific window of historical data to determine the "Average True Range." This tells the tool how much the price typically moves over a set period. By looking at this average, the script can distinguish between normal market noise and significant price movements.
2. Defining the Buffer Zone Depending on your settings, the script creates a "buffer" or a safety margin.
- In its standard mode, it calculates a dynamic distance based on the volatility average multiplied by a specific factor.
- Alternatively, it can be set to a fixed price distance if preferred. This buffer ensures that the indicator doesn't react too quickly to minor fluctuations, focusing instead on substantial shifts in direction.
3. Identifying Price Pivots The logic then tracks the relationship between the current closing price and the previous boundary line. It follows three specific rules:
- Persistence: If the price hasn't broken out of the previous boundary, the line stays put.
- Trend Following: If the price moves significantly in one direction and stays there, the indicator adjusts its level to account for that new "floor" or "ceiling." It effectively "re-anchors" itself once a new trend is established.
- Dynamic Adjustment: When a price crossover occurs, the script calculates a new boundary based on the current price plus or minus that calculated buffer zone.
Practical Application
For a user, this means the indicator provides a visual representation of support and resistance that moves with the market. Rather than a static line, it creates a trailing boundary that "breathes" with the market's volatility. When the price pushes past these levels significantly, it signals a potential shift in market structure, providing a clearer picture of where the current momentum is leading.
//+------------------------------------------------------------------+
//| Volatility.Pivot.mq4 |
//+------------------------------------------------------------------+
#property copyright "thanks to S.B.T. (Japan)"
#property link "http://sufx.core.t3-ism.net/" //<<< convert this from VT, thanks mate !!!
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkSeaGreen
//---- input parameters
extern double atr_range=100;
extern double ima_range = 10;
extern double atr_factor=3;
extern int Mode = 0;
extern double DeltaPrice = 30;
//---- buffers
double TrStop[];
double ATR[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0, TrStop);
SetIndexStyle(1, DRAW_NONE);
SetIndexBuffer(1, ATR);
string short_name = "!! RisenbergVolatilityCapture";
IndicatorShortName(short_name);
SetIndexLabel(1,"range base");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
int limit;
int i;
double DeltaStop;
limit = Bars;
for(i = 0; i < limit; i ++) {
ATR[i] = iATR(NULL,0,atr_range,i);
}
for(i = limit - 1; i >= 0; i --) {
if (Mode == 0) {
DeltaStop = iMAOnArray(ATR,0,ima_range,0,MODE_EMA,i) * atr_factor;
//DeltaStop = iATR(NULL,0,atr_range,i) * atr_factor;
} else {
DeltaStop = DeltaPrice*Point;
}
if (Close[i] == TrStop[i + 1]) {
TrStop[i] = TrStop[i + 1];
} else {
if (Close[i+1]<TrStop[i+1] && Close[i]<TrStop[i+1]) {
TrStop[i] = MathMin(TrStop[i + 1], Close[i] + DeltaStop);
} else {
if (Close[i+1]>TrStop[i+1] && Close[i]>TrStop[i+1]) {
TrStop[i] = MathMax(TrStop[i+1], Close[i] - DeltaStop);
} else {
if (Close[i] > TrStop[i+1]) TrStop[i] = Close[i] - DeltaStop; else TrStop[i] = Close[i] + DeltaStop;
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments