Chaikin's Volatility (2 lines)

Download script
Author: Kalenzo
Chaikin's Volatility (2 lines)

Overview

The Chaikin's Volatility indicator is a technical analysis tool designed to measure and visualize market volatility by analyzing the relationship between price ranges and their smoothed averages. Unlike standard indicators that might only look at the closing price, this tool focuses on the "spread" of price action—specifically the distance between the highest and lowest points reached during a specific timeframe.

How the Logic Works

The script processes market data through three distinct layers to provide a clear picture of volatility trends:

1. Measuring Price Range

First, the indicator calculates the raw volatility for every individual candle on the chart. It does this by subtracting the low price from the high price. This gives us a baseline measurement of how much "room" the price moved within each specific period.

2. Smoothing the Data (Moving Averages)

Because raw market data can be very "noisy" and jump around unpredictably, the script applies a smoothing process to these ranges. It calculates two different types of Exponential Moving Averages (EMA) based on the price ranges:

  • Fast Average: Tracks shorter-term fluctuations to react quickly to recent changes.
  • Slow Average: Tracks longer-term trends to provide a broader perspective of market behavior.

By using exponential averages, the indicator gives more weight to recent price action while still maintaining a smooth line that is easier for a trader to read.

3. Calculating Volatility Percentages

The final step is where the actual "Chaikin" logic occurs. The script compares the current smoothed average against its own past values (using specific time offsets). It calculates the percentage of change between these two points:

  • Fast Volatility: Shows how much the short-term volatility has changed over a set period.
  • Slow Volatility: Shows how much the long-term volatility has changed over an even larger period.

What This Means for the User

The resulting lines on your chart represent the momentum of volatility.

Instead of just telling you if the market is moving, these indicators tell you if the intensity of the movement is increasing or decreasing. When these values rise, it indicates that price swings are becoming wider and more aggressive; when they fall, it suggests the market is stabilizing or compressing. By observing the interaction between the fast and slow volatility lines, traders can better anticipate periods of high-intensity market activity versus periods of consolidation.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Chaikin's Volatility (2 lines)
//+------------------------------------------------------------------+
//|                                         Chaikin's Volatility.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Red
#property indicator_color2 Blue
 
//---- input parameters
extern int       iPeriod=13;
extern int       maPeriod=13;
extern int       maSlowPeriod=26;

//---- buffers
double chakin[];
double Slowchakin[];
double hl[];
double emahl[];
double Slowemahl[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,chakin);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Slowchakin);
   
   SetIndexStyle(2,DRAW_NONE);
   SetIndexBuffer(2,hl);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexBuffer(3,emahl);
   SetIndexStyle(4,DRAW_NONE);
   SetIndexBuffer(4,Slowemahl);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//----
   for(int c = 0 ;c <= limit ;c++) hl[c]=High[c]-Low[c];
   for(int e = 0 ;e <= limit ;e++) 
   {
      emahl[e]= iMAOnArray(hl,0,maPeriod,0,MODE_EMA,e);
      Slowemahl[e]= iMAOnArray(hl,0,maSlowPeriod,0,MODE_EMA,e);
   }
   
   for(int i = 0 ;i <= limit-20 ;i++)
   {
      
      chakin[i] = ( (emahl[i]-emahl[i+iPeriod])/emahl[i+iPeriod] ) *100;  
      Slowchakin[i] = ( (Slowemahl[i]-Slowemahl[i+iPeriod])/Slowemahl[i+maSlowPeriod] ) *100; 
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments