Calculation:

To calculate Chaikin Volatility:

First, calculate an exponential moving average (normally 10 days) of the difference between High and Low for each period:

EMA [H-L]

Next, calculate the percentage change in the moving average over a further period (normally 10 days):

( EMA [H-L] - EMA [H-L 10 days ago] ) / EMA [ H-L 10 days ago] * 100




Source Code "CHV Chaikin Volatility":

function init()
{
   CHV.createParameter("Period", 10);

   CHV.createBuffer("CHV");
   CHV.setBufferColor("CHV", 'lime');
   CHV.setBufferDrawStyle("CHV", DrawStyle.LINE);

   CHV.setAutoChangeMaxMin("CHV");

   CHV.addLevel(0, "white");
}

function start()
{
   var period = CHV.parameter("Period");

   CHV.label = "CHV(" + period + ")";

   var num = Shared.numberOfQuotes();
   var bufHL = new Array(num);
   var bufHLP = new Array(num);
   for (var j = 0; j < num; ++j) {
     bufHL[j] = Shared.high(j) - Shared.low(j);
   }

   var bufHLEMA = Shared.ema(period, bufHL);

   var bufTempCHV = new Array(num);
   for (var j = 0; j < period; ++j) {
      bufTempCHV[j] = 0;
   }

   for (var j = period; j < num; ++j) {
     var fValue = (bufHLEMA[j] - bufHLEMA[j - period])
        / bufHLEMA[j - period]
        * 100;

     bufTempCHV[j] = fValue;
   }

   CHV.setBufferData("CHV", bufTempCHV);
}