Atr_3v1_4
Download scriptThis script is designed as a custom technical indicator for the MetaTrader platform to help traders visualize and analyze market volatility and trading volume dynamics. Rather than showing standard price movements, it focuses on the relationship between relative price fluctuations and historical volume averages.
Core Logic Overview
The indicator works by comparing two primary metrics: Relative Volatility and Normalized Volume. By calculating these values simultaneously, the script identifies whether the current market activity is "over-performing" or "under-performing" relative to historical norms.
Key Components of the Analysis
-
Volatility Scaling: The tool takes the Average True Range (ATR)—a common measure of market volatility—and scales it against a much larger historical timeframe. This allows the user to see how the price movement of the current moment compares to the general "noise" of the past several hundred bars.
-
Volume Normalization: The script calculates a moving average of the trading volume over a specific period. It then takes the current volume and scales it against this average. This helps distinguish between high-activity periods that are normal for the market and those that represent significant, unusual spikes in participation.
-
The Comparative Calculation: The heart of the logic lies in subtracting the Scaled Volatility from the Normalized Volume. By finding the difference between these two values, the indicator highlights "unbalanced" market behavior.
- When the volume significantly outweighs the price volatility, it suggests a strong underlying move with high conviction.
- When volatility outweighs the volume, it may suggest "thin" trading where small amounts of activity are causing large price swings.
Visual Representation
The indicator displays these findings in a separate window on your chart:
- Histograms: The results are plotted as bars that change based on whether the calculation is positive or negative.
- Color Coding: The script uses different colors (Red and Blue) to distinguish between upward and downward discrepancies, allowing for a quick glance at market sentiment.
- Reference Levels: A central zero-line acts as the "equilibrium" point. The indicator provides visual boundaries (set by a percentage parameter) to help traders identify extreme conditions where market behavior deviates significantly from the norm.
Summary for the Trader
Essentially, this tool filters out the noise of standard price action to show you the intensity of the market. It tells you when the volume is backing up a move or when the price is moving independently of heavy trading activity, helping you identify high-conviction trends more effectively.
//+------------------------------------------------------------------+
//| Atr_3v1.mq4 |
//| Copyright © 2006, HexSys Software Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, HexSys Software Corp."
#property link ""
#property indicator_separate_window
#property indicator_minimum -110
#property indicator_maximum 110
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Yellow
#property indicator_color5 Red
//---- input parameters
extern int AtrMAX=480;
extern int Percent=50;
extern int mBars=480;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY, 2);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY, 2);
//SetIndexArrow(1,241);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY, 2);
//SetIndexArrow(2,242);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer5);
//*
IndicatorDigits(2);
SetLevelStyle(STYLE_DOT,1,Yellow);
SetLevelValue(0,Percent);
SetLevelValue(1,-Percent);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
//for(int i=0;i<counted_bars;i++)
double s=0; int j=0;
double Ext1=0,Ext4=0;
for(j=1;j<=AtrMAX;j++) s=s+Volume[j];
s=s/(AtrMAX);
//for zero bar
Ext1=(iATR(NULL,0,1,0)*100) / iATR(NULL,0,AtrMAX,0);
Ext4=(Volume[0]*100) / s;
ExtMapBuffer1[0]=Ext4-Ext1;
//if (Ext4-Ext1>=0) {ExtMapBuffer2[0]=Ext4-Ext1; ExtMapBuffer3[0]=0;}
//if (Ext4-Ext1<0) {ExtMapBuffer3[0]=Ext4-Ext1; ExtMapBuffer2[0]=0;}
//for All bars...
for(int i=1;i<mBars;i++)
{
Ext1=(iATR(NULL,0,1,i)*100) / iATR(NULL,0,AtrMAX,i);
Ext4=(Volume[i]*100) / s;
if (Ext4-Ext1>=0) {ExtMapBuffer2[i]=Ext4-Ext1; ExtMapBuffer3[i]=0;}
if (Ext4-Ext1<0) {ExtMapBuffer3[i]=Ext4-Ext1; ExtMapBuffer2[i]=0;}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments