Author: Copyright � 2005, Luis Guilherme Damiani
ATR_ratio

This tool is designed to help traders understand the relationship between short-term market volatility and long-term market volatility. Instead of looking at price alone, it analyzes how "fast" the market is moving compared to its historical average behavior over different timeframes.

Core Concept: The Volatility Ratio

The logic functions by calculating two distinct measurements of market "noise" or range (known as Average True Range):

  1. Short-Term Perspective: It captures the immediate, recent price action over a small window of time.
  2. Long-Term Perspective: It captures the broader, historical price movement over a significantly larger window of time.

By dividing the short-term measurement by the long-term measurement, the tool generates a Ratio. This ratio tells you whether the current market environment is becoming more erratic (higher ratio) or more stable (lower ratio) relative to its usual behavior.

How it Works on Your Chart

The script visualizes this relationship in a separate window below your main price chart using two primary lines:

  • The Volatility Ratio Line: This represents the actual calculation. When this line moves upward, it indicates that short-term volatility is increasing compared to the long-term trend. When it moves downward, it suggests the market is cooling off or becoming more compressed.
  • The Threshold Level: The tool includes a fixed horizontal reference point (a trigger level). This acts as a visual "yardstick." By observing where the Volatility Ratio line sits in relation to this horizontal line, traders can identify specific moments when short-term fluctuations exceed a pre-defined intensity threshold.

Summary for the User

Essentially, this indicator filters out the "background noise" of the market to show you the relative strength of current price swings. It allows you to see at a glance if the market is currently experiencing an unusual burst of activity or if it is behaving in a more predictable, calmer manner than usual.

Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
ATR_ratio
//+------------------------------------------------------------------+
//|                                                    ATR ratio.mq4 |
//|                         Copyright © 2005, Luis Guilherme Damiani |
//|                                      http://www.damianifx.com.br |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Luis Guilherme Damiani"
#property link      "http://www.damianifx.com.br"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int    short_atr = 7;
extern int    long_atr = 49;
extern double triglevel = 0.87;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, ExtMapBuffer2);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("ATRr(" + short_atr + ", " + long_atr + ")");
   SetIndexLabel(0, "ATRrTL");
   SetIndexLabel(1, "ATRr"); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   for(int i = 0; i < Bars - counted_bars; i++)
     {
       ExtMapBuffer1[i] = triglevel;
       double dAtrShort = iATR(NULL, 0, short_atr, i);
       double dAtrLong = iATR(NULL, 0, long_atr, i);
       if(dAtrLong != 0) 
           ExtMapBuffer2[i] = dAtrShort / dAtrLong;   
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments