ATR Darma
Download scriptThe ATR Darma is a custom technical analysis tool designed to provide traders with a visual representation of market volatility and its underlying trends. Rather than looking at price alone, this indicator focuses on how much the price "swings" over specific periods, helping you understand whether the market is becoming more turbulent or settling into a calmer state.
Core Logic and Functionality
The script operates by processing two distinct layers of data to give you a complete picture of market movement:
1. Volatility Measurement (The ATR Line) The foundation of this tool is the Average True Range (ATR). This identifies the average range of price movement over a set number of candles (defaulting to 30). Instead of telling you which direction the price is going, it tells you how "noisy" or "active" the market is. A higher value indicates significant price swings, while a lower value suggests consolidation or quieter trading activity.
2. Trend Smoothing (The Moving Average) To make this volatility data easier to interpret, the script applies a second layer of logic: a Moving Average (MA) calculated directly from the ATR values. By taking the average of the volatility over another period (defaulting to 20), the tool filters out minor "blips" and highlights the broader trend of market activity. This allows you to see if the overall intensity of the market is steadily increasing, decreasing, or remaining stable.
How it appears on your chart
The indicator occupies its own separate window below your main price chart. It renders two primary visual lines:
- The ATR Line: Represents the raw volatility data.
- The Moving Average Line: Represents the smoothed trend of that volatility.
Practical Application for Traders
By observing these two lines together, you can identify specific market conditions:
- Expansion: When both lines move upward, it indicates that price swings are getting larger, which often precedes a significant breakout or a high-momentum trend.
- Contraction: When both lines move downward, the market is "cooling off," suggesting a period of low volatility or a range-bound market where big moves are less likely.
- Trend Confirmation: The relationship between the raw ATR and its Moving Average helps in identifying when a burst of volatility is a lasting trend versus a temporary spike.
This tool is primarily intended for traders who want to manage risk by understanding market "heartbeats"—helping you stay informed about the environment's intensity before making your next move.
//+------------------------------------------------------------------+
//| ATR Darma.mq4 |
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Purple
#property indicator_color2 LightSeaGreen
#property indicator_level1 1
//---- indicator parameters
extern int ATR_Period = 30;
extern int SignalLine_Period = 20;
extern int SignalLineShift = 0;
extern int SignalLineMa_Method = 0; // 0 SMA , 1 EMA , 2 SMMA , 3 LWMA
extern int ShowBars = 500;
//---- indicator buffers
double ATR_Buffer[];
double MA_ATR_Buffer[];
int draw_begin0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
//---- drawing settings
draw_begin0 = ATR_Period;
SetIndexEmptyValue(1,0.0000);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(1,ATR_Buffer);
SetIndexLabel(1,"ATR");
SetIndexDrawBegin(1,draw_begin0);
SetIndexEmptyValue(0,0.0000);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,MA_ATR_Buffer);
SetIndexLabel(0," ("+SignalLine_Period+") Period MA of ATR");
SetIndexDrawBegin(0,draw_begin0);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ATR Darma");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start() {
int limit,i,shift;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<1)
for(i=1;i<=draw_begin0;i++)
MA_ATR_Buffer[Bars-i]=0; ATR_Buffer[Bars-i]=0;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//limit=Bars-counted_bars;
limit = ShowBars;
if (ShowBars >= Bars) limit = Bars - 1;
//-----------------------------------------------------------------------------------------------------------------
//---- ATR_Buffer
for(i=0; i<limit; i++)
ATR_Buffer[i] = iATR(Symbol(),0,ATR_Period,i);
//---- MA_ATR_Buffer
for(i=0; i<limit; i++)
MA_ATR_Buffer[i]=iMAOnArray(ATR_Buffer,0,SignalLine_Period,SignalLineShift,SignalLineMa_Method,i);
//-----------------------------------------------------------------------------------------------------------------
//---- done
return(0);
}
Comments