VolATR
Download scriptThis tool is designed to help traders visualize and interpret market volatility by creating a dual-layered visual aid in a separate window on your trading platform. Rather than looking at raw price action, it focuses on the "movement intensity" of the market.
How It Works
The indicator operates using two distinct mathematical layers to provide a clear picture of market behavior:
1. The Volatility Base (Red Line) The first layer calculates the Average True Range (ATR). In simple terms, this measures how much an asset typically moves over a specific number of bars. By plotting this as a line, the tool shows you the "pulse" of the market—when the line is high, the market is moving aggressively; when it is low, the market is relatively quiet or range-bound.
2. The Smoothed Trend (Navy Line) Because raw volatility can often be "noisy" or jumpy, the script adds a second layer. It takes the data from the first volatility line and applies a smoothing filter to it. This creates a secondary line that follows the general trend of the volatility. This helps filter out minor fluctuations, allowing you to see the broader cycle of market activity more clearly.
Key Customizations
The tool allows you to adjust three main factors to fit your specific trading style:
- ATR Period: Determines how many recent price bars are used to calculate the initial volatility measurement.
- Smooth Period: Controls how much data is averaged out for the second line. A higher number will result in a much smoother, slower-reacting curve.
- Smoothing Type: Allows you to choose the specific mathematical method (such as Simple, Exponential, Smoothed, or Linear Weighted) used to calculate that second trend line.
Practical Use
By observing these two lines together, traders can better identify periods of high-activity breakouts versus periods of consolidation. The goal is to provide a clearer understanding of "market energy," helping you decide whether the current environment is suitable for your specific trading strategy.
//+------------------------------------------------------------------+
//| VolAtr.mq4 |
//| MetaQuotes |
//| http://www.alpari-idc.ru/ru/experts/articles/ |
//+------------------------------------------------------------------+
#property copyright "MetaQuotes"
#property link "http://www.alpari-idc.ru/ru/experts/articles/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Navy
//---- input parameters
extern int ATRper=8;
extern int SmoothPer=5;
extern int SmoothType=0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
string type;
switch(SmoothType)
{
case MODE_EMA: type="EMA";break;
case MODE_SMMA: type="SMMA";break;
case MODE_LWMA: type="LWMA";break;
default: type="SMA";SmoothType=0;break; // åñëè íè îäèí âàðèàíò íå ïîäîøåë
}
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"ATR("+ATRper+")");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,"Sm("+"ATR("+ATRper+"),"+SmoothPer+")"+type);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,cnt;
if (counted_bars==0)
{
limit=Bars-ATRper-1;
for(cnt=limit;cnt>=0;cnt--)
{
ExtMapBuffer1[cnt]=iATR(NULL,0,ATRper,cnt);
}
for(cnt=limit-SmoothPer;cnt>=0;cnt--)
{
ExtMapBuffer2[cnt]=iMAOnArray(ExtMapBuffer1,0,SmoothPer,0,SmoothType,cnt);
}
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments