```
# Cumulative Volume Delta with Chaikin Money Flow + Chaikin Osc
# tomsk
# 1.6.2020
# Cumulative Volume Delta
#
# The length of the accumulation is user controlled. The cumulative bar
# is the sum of the deltas for the past 10 bars. Change that length to
# 252 (a year in days) then plot something like AAPL. Very interesting.
#
# LongShort
# 5.7.2019
declare lower;
script normalizePlot {
input data = close;
input newRngMin = -1;
input newRngMax = 1;
def hhData = HighestAll( data );
def llData = LowestAll( data );
plot nr = ((( newRngMax - newRngMin ) * ( data - llData )) / ( hhData - llData )) + newRngMin;
}
input CVDlength = 10;
input CMFlength = 21;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
def Delt = buying - selling;
plot Delta = normalizePlot(Delt, -0.4, 0.4);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.hide();
plot zero = 0;
Zero.SetDefaultColor(GetColor(5));
plot CumulativeVolumeDelta = normalizePlot(sum(Delta,CVDlength), -0.4, 0.4);
CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
# TOS Chaikin Money Flow
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
#
def tmp_var =
if high == low then
volume
else
(close - low - (high - close)) / (high - low) * volume
;
def sum_close = sum(tmp_var, CMFlength);
def total = sum(volume, CMFlength);
plot CMF =
if total == 0 then
0
else
sum_close / total
;
CMF.SetDefaultColor(Color.PINK);
CMF.SetLineWeight(2);
# Chaikin Oscillator
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
#
input colorNormLength = 14;
input fastLength = 3;
input slowLength = 10;
def acc = AccumDist(high, close, low, open, volume);
def shortXAvg = ExpAverage(acc, fastLength);
def longXAvg = ExpAverage(acc, slowLength);
plot ChaikinOsc = normalizePlot(shortXAvg - longXAvg, -0.4, 0.4);
ChaikinOsc.DefineColor("Highest", Color.YELLOW);
ChaikinOsc.DefineColor("Lowest", Color.LIGHT_RED);
ChaikinOsc.AssignNormGradientColor(colorNormLength, ChaikinOsc.color("Lowest"), ChaikinOsc.color("Highest"));
ChaikinOsc.SetLineWeight(2);
# End Cumulative Volume Delta with Chaikin Money Flow + Chaikin Osc
```