More Information about:
Link: 1) http://www.onlinetradingconcepts.com/TechnicalAnalysis/AccumulationDistribution.html




Calculation:

A certain share of the daily volume is added to or subtracted from the current accumulated value of the indicator. The nearer the closing price to the maximum price of the day is, the higher the added share will be. The nearer the closing price to the minimum price of the day is, the greater the subtracted share will be. If the closing price is exactly in between the maximum and minimum of the day, the indicator value remains unchanged.

A/D(i) =((CLOSE(i) - LOW(i)) - (HIGH(i) - CLOSE(i)) * VOLUME(i) / (HIGH(i) - LOW(i)) + A/D(i-1)

Where:

A/D(i) - importance of the Indicator of the Accumulation/Distribution for the current bar;
CLOSE(i) - the price of the closing the bar;
LOW(i) - the minimum price of the bar;
HIGH(i) - the maximum price of the bar;
VOLUME(i) - volume;
A/D(i-1) - importance of the Indicator of the Accumulation/Distribution for previous bar.


Source Code "AD - Accumulation/Distribution":

function init()
{
   AD.label = "A/D";
   AD.createBuffer("AD");
   AD.setBufferColor("AD", 'lime');
   AD.setBufferDrawStyle("AD", DrawStyle.LINE);
   AD.setAutoChangeMaxMin("AD");
}

function start()
{
   var num = Shared.numberOfQuotes();
   var buf = new Array(num);

   for (var i = 0; i < num; ++i) {
     var fHigh = Shared.high(i);
     var fLow = Shared.low(i);
     var fClose = Shared.close(i);
     var fAD = ((fClose - fLow) - (fHigh - fClose));
     if (fAD != 0) {
        var fDiff = fHigh - fLow;
        fAD /= fDiff;
        fAD *= Shared.volume(i);
     }

     buf[i] = fAD;
     if (i != 0) {
        buf[i] += buf[i - 1];
     }
   }
   AD.setBufferData("AD", buf);
}