Trend Volume Accumulations

https://www.tradingview.com/script/bpfxYC3a-Trend-Volume-Accumulations/

Deeply inspired by the Weiss wave indicator, the following indicator aims to return the accumulations of rising and declining volume of a specific trend. Positive waves are constructed using rising volume while negative waves are using declining volume. The trend is determined by the sign of the rise of a rolling linear regression.

Settings

  • Length : Period of the indicator.

  • Src : Source of the indicator.

  • Linearity : Allows the output of the indicator to look more linear.

  • Mult : the multiplicative factor of both the upper and lower levels

  • Gradient : Use a gradient as color for the waves, true by default.

Usages

The trend volume accumulations (TVA) indicator allows determining the current price trend while taking into account volume, with blue colors representing an uptrend and red colors representing a downtrend. The first motivation behind this indicator was to see if movements mostly made of declining volume were different from ones made of rising volume.

Waves of low amplitude represent movements with low trading activity.

Using higher values of Linearity allows giving less importance to individual volumes values, thus returning more linear waves as a result.

The indicator includes two levels, the upper one is derived from the cumulative mean of the waves based on rising volume, while the lower one is based on the cumulative mean of the waves based on declining volume, when a wave reaches a level we can expect the current trend to reverse. You can use different values of mult to control the distance from 0 of each level.

Source Code

// This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=4
study("Trend Volume Accumulations","TVA")
length = input(14)
src = input(close)
smo = input(3,"Linearity")
mult = input(5)
grad = input(true,"Gradient")
//----
gradient(x,y)=>
var css = array.new_color(na)
if barstate.isfirst
if y
array.push(css,#00BCD4), array.push(css,#00BBD4), array.push(css,#00BAD4), array.push(css,#00BAD4), array.push(css,#00B9D4), array.push(css,#00B9D4), array.push(css,#00B8D4), array.push(css,#01B8D5), array.push(css,#01B7D5), array.push(css,#01B7D5), array.push(css,#01B6D5), array.push(css,#01B6D5), array.push(css,#01B5D5), array.push(css,#02B5D6), array.push(css,#02B4D6), array.push(css,#02B4D6), array.push(css,#02B3D6), array.push(css,#02B3D6), array.push(css,#02B2D6), array.push(css,#03B2D6), array.push(css,#03B1D7), array.push(css,#03B1D7), array.push(css,#03B0D7), array.push(css,#03B0D7), array.push(css,#03AFD7), array.push(css,#04AFD7), array.push(css,#04AED8), array.push(css,#04AED8), array.push(css,#04ADD8), array.push(css,#04ADD8), array.push(css,#04ACD8), array.push(css,#05ACD8), array.push(css,#05ABD8), array.push(css,#05ABD9), array.push(css,#05AAD9), array.push(css,#05AAD9), array.push(css,#05A9D9), array.push(css,#06A9D9), array.push(css,#06A8D9), array.push(css,#06A8DA), array.push(css,#06A7DA), array.push(css,#06A7DA), array.push(css,#06A6DA), array.push(css,#07A6DA), array.push(css,#07A5DA), array.push(css,#07A5DB), array.push(css,#07A4DB), array.push(css,#07A4DB), array.push(css,#07A3DB), array.push(css,#08A3DB), array.push(css,#08A2DB), array.push(css,#08A2DB), array.push(css,#08A1DC), array.push(css,#08A1DC), array.push(css,#08A0DC), array.push(css,#09A0DC), array.push(css,#099FDC), array.push(css,#099FDC), array.push(css,#099EDD), array.push(css,#099EDD), array.push(css,#099DDD), array.push(css,#0A9DDD), array.push(css,#0A9CDD), array.push(css,#0A9CDD), array.push(css,#0A9BDD), array.push(css,#0A9BDE), array.push(css,#0A9ADE), array.push(css,#0B99DE), array.push(css,#0B99DE), array.push(css,#0B98DE), array.push(css,#0B98DE), array.push(css,#0B97DF), array.push(css,#0B97DF), array.push(css,#0C96DF), array.push(css,#0C96DF), array.push(css,#0C95DF), array.push(css,#0C95DF), array.push(css,#0C94DF), array.push(css,#0C94E0), array.push(css,#0D93E0), array.push(css,#0D93E0), array.push(css,#0D92E0), array.push(css,#0D92E0), array.push(css,#0D91E0), array.push(css,#0D91E1), array.push(css,#0E90E1), array.push(css,#0E90E1), array.push(css,#0E8FE1), array.push(css,#0E8FE1), array.push(css,#0E8EE1), array.push(css,#0E8EE2), array.push(css,#0F8DE2), array.push(css,#0F8DE2), array.push(css,#0F8CE2), array.push(css,#0F8CE2), array.push(css,#0F8BE2), array.push(css,#0F8BE2), array.push(css,#108AE3), array.push(css,#108AE3), array.push(css,#1089E3), array.push(css,#1089E3), array.push(css,#1088E3), array.push(css,#1088E3), array.push(css,#1187E4), array.push(css,#1187E4), array.push(css,#1186E4), array.push(css,#1186E4), array.push(css,#1185E4), array.push(css,#1185E4), array.push(css,#1284E4), array.push(css,#1284E5), array.push(css,#1283E5), array.push(css,#1283E5), array.push(css,#1282E5), array.push(css,#1282E5), array.push(css,#1381E5), array.push(css,#1381E6), array.push(css,#1380E6), array.push(css,#1380E6), array.push(css,#137FE6), array.push(css,#137FE6), array.push(css,#147EE6), array.push(css,#147EE7), array.push(css,#147DE7), array.push(css,#147DE7), array.push(css,#147CE7), array.push(css,#147CE7), array.push(css,#157BE7), array.push(css,#157BE7), array.push(css,#157AE8), array.push(css,#157AE8), array.push(css,#1579E8), array.push(css,#1579E8), array.push(css,#1678E8), array.push(css,#1677E8), array.push(css,#1677E9), array.push(css,#1676E9), array.push(css,#1676E9), array.push(css,#1675E9), array.push(css,#1775E9), array.push(css,#1774E9), array.push(css,#1774E9), array.push(css,#1773EA), array.push(css,#1773EA), array.push(css,#1772EA), array.push(css,#1872EA), array.push(css,#1871EA), array.push(css,#1871EA), array.push(css,#1870EB), array.push(css,#1870EB), array.push(css,#186FEB), array.push(css,#196FEB), array.push(css,#196EEB), array.push(css,#196EEB), array.push(css,#196DEB), array.push(css,#196DEC), array.push(css,#196CEC), array.push(css,#1A6CEC), array.push(css,#1A6BEC), array.push(css,#1A6BEC), array.push(css,#1A6AEC), array.push(css,#1A6AED), array.push(css,#1A69ED), array.push(css,#1B69ED), array.push(css,#1B68ED), array.push(css,#1B68ED), array.push(css,#1B67ED), array.push(css,#1B67EE), array.push(css,#1B66EE), array.push(css,#1C66EE), array.push(css,#1C65EE), array.push(css,#1C65EE), array.push(css,#1C64EE), array.push(css,#1C64EE), array.push(css,#1C63EF), array.push(css,#1D63EF), array.push(css,#1D62EF), array.push(css,#1D62EF), array.push(css,#1D61EF), array.push(css,#1D61EF), array.push(css,#1D60F0), array.push(css,#1E60F0), array.push(css,#1E5FF0), array.push(css,#1E5FF0), array.push(css,#1E5EF0), array.push(css,#1E5EF0), array.push(css,#1E5DF0), array.push(css,#1F5DF1), array.push(css,#1F5CF1), array.push(css,#1F5CF1), array.push(css,#1F5BF1), array.push(css,#1F5BF1), array.push(css,#1F5AF1), array.push(css,#205AF2), array.push(css,#2059F2), array.push(css,#2059F2), array.push(css,#2058F2), array.push(css,#2058F2), array.push(css,#2057F2), array.push(css,#2157F3)
else
array.push(css,#FFAC00), array.push(css,#FFAB00), array.push(css,#FFAA00), array.push(css,#FFA900), array.push(css,#FFA800), array.push(css,#FFA800), array.push(css,#FFA700), array.push(css,#FFA600), array.push(css,#FFA500), array.push(css,#FFA400), array.push(css,#FFA400), array.push(css,#FFA300), array.push(css,#FFA200), array.push(css,#FFA100), array.push(css,#FFA100), array.push(css,#FFA000), array.push(css,#FF9F00), array.push(css,#FF9E00), array.push(css,#FF9D00), array.push(css,#FF9D00), array.push(css,#FF9C00), array.push(css,#FF9B00), array.push(css,#FF9A00), array.push(css,#FF9A00), array.push(css,#FF9900), array.push(css,#FF9800), array.push(css,#FF9700), array.push(css,#FF9600), array.push(css,#FF9600), array.push(css,#FF9500), array.push(css,#FF9400), array.push(css,#FF9300), array.push(css,#FF9300), array.push(css,#FF9200), array.push(css,#FF9100), array.push(css,#FF9000), array.push(css,#FF8F00), array.push(css,#FF8F00), array.push(css,#FF8E00), array.push(css,#FF8D00), array.push(css,#FF8C00), array.push(css,#FF8C00), array.push(css,#FF8B00), array.push(css,#FF8A00), array.push(css,#FF8900), array.push(css,#FF8800), array.push(css,#FF8800), array.push(css,#FF8700), array.push(css,#FF8600), array.push(css,#FF8500), array.push(css,#FF8500), array.push(css,#FF8400), array.push(css,#FF8300), array.push(css,#FF8200), array.push(css,#FF8100), array.push(css,#FF8100), array.push(css,#FF8000), array.push(css,#FF7F00), array.push(css,#FF7E00), array.push(css,#FF7E00), array.push(css,#FF7D00), array.push(css,#FF7C00), array.push(css,#FF7B00), array.push(css,#FF7A00), array.push(css,#FF7A00), array.push(css,#FF7900), array.push(css,#FF7800), array.push(css,#FF7700), array.push(css,#FF7700), array.push(css,#FF7600), array.push(css,#FF7500), array.push(css,#FF7400), array.push(css,#FF7300), array.push(css,#FF7300), array.push(css,#FF7200), array.push(css,#FF7100), array.push(css,#FF7000), array.push(css,#FF7000), array.push(css,#FF6F00), array.push(css,#FF6E00), array.push(css,#FF6D00), array.push(css,#FF6C00), array.push(css,#FF6C00), array.push(css,#FF6B00), array.push(css,#FF6A00), array.push(css,#FF6900), array.push(css,#FF6900), array.push(css,#FF6800), array.push(css,#FF6700), array.push(css,#FF6600), array.push(css,#FF6500), array.push(css,#FF6500), array.push(css,#FF6400), array.push(css,#FF6300), array.push(css,#FF6200), array.push(css,#FF6200), array.push(css,#FF6100), array.push(css,#FF6000), array.push(css,#FF5F00), array.push(css,#FF5E00), array.push(css,#FF5E00), array.push(css,#FF5D00), array.push(css,#FF5C00), array.push(css,#FF5B00), array.push(css,#FF5A00), array.push(css,#FF5A00), array.push(css,#FF5900), array.push(css,#FF5800), array.push(css,#FF5700), array.push(css,#FF5700), array.push(css,#FF5600), array.push(css,#FF5500), array.push(css,#FF5400), array.push(css,#FF5300), array.push(css,#FF5300), array.push(css,#FF5200), array.push(css,#FF5100), array.push(css,#FF5000), array.push(css,#FF5000), array.push(css,#FF4F00), array.push(css,#FF4E00), array.push(css,#FF4D00), array.push(css,#FF4C00), array.push(css,#FF4C00), array.push(css,#FF4B00), array.push(css,#FF4A00), array.push(css,#FF4900), array.push(css,#FF4900), array.push(css,#FF4800), array.push(css,#FF4700), array.push(css,#FF4600), array.push(css,#FF4500), array.push(css,#FF4500), array.push(css,#FF4400), array.push(css,#FF4300), array.push(css,#FF4200), array.push(css,#FF4200), array.push(css,#FF4100), array.push(css,#FF4000), array.push(css,#FF3F00), array.push(css,#FF3E00), array.push(css,#FF3E00), array.push(css,#FF3D00), array.push(css,#FF3C00), array.push(css,#FF3B00), array.push(css,#FF3B00), array.push(css,#FF3A00), array.push(css,#FF3900), array.push(css,#FF3800), array.push(css,#FF3700), array.push(css,#FF3700), array.push(css,#FF3600), array.push(css,#FF3500), array.push(css,#FF3400), array.push(css,#FF3400), array.push(css,#FF3300), array.push(css,#FF3200), array.push(css,#FF3100), array.push(css,#FF3000), array.push(css,#FF3000), array.push(css,#FF2F00), array.push(css,#FF2E00), array.push(css,#FF2D00), array.push(css,#FF2D00), array.push(css,#FF2C00), array.push(css,#FF2B00), array.push(css,#FF2A00), array.push(css,#FF2900), array.push(css,#FF2900), array.push(css,#FF2800), array.push(css,#FF2700), array.push(css,#FF2600), array.push(css,#FF2600), array.push(css,#FF2500), array.push(css,#FF2400), array.push(css,#FF2300), array.push(css,#FF2200), array.push(css,#FF2200), array.push(css,#FF2100), array.push(css,#FF2000), array.push(css,#FF1F00), array.push(css,#FF1F00), array.push(css,#FF1E00), array.push(css,#FF1D00), array.push(css,#FF1C00), array.push(css,#FF1B00), array.push(css,#FF1B00), array.push(css,#FF1A00), array.push(css,#FF1900), array.push(css,#FF1800), array.push(css,#FF1800), array.push(css,#FF1700), array.push(css,#FF1600), array.push(css,#FF1500), array.push(css,#FF1400), array.push(css,#FF1400), array.push(css,#FF1300), array.push(css,#FF1200), array.push(css,#FF1100), array.push(css,#FF1100)
array.get(css,round(x*199))
//----
rising_bull = 0.,rising_bear = 0.
declining_bull = 0.,declining_bear = 0.
v = volume
os = wma(src,length) - sma(src,length)
rv = sma(change(v) > 0 ? v : 0,smo)
dv = sma(change(v) < 0 ? v : 0,smo)
rising_bull := os > 0 ? rising_bull[1] + rv : 0
rising_bear := os < 0 ? rising_bear[1] + rv : 0
declining_bull := os > 0 ? declining_bull[1] - dv : 0
declining_bear := os < 0 ? declining_bear[1] - dv : 0
a = cum(rising_bull+rising_bear)/bar_index*mult
b = cum(declining_bull+declining_bear)/bar_index*mult
//----
plot(grad ? na : rising_bull,"Rising Bull",#2157f3,style=plot.style_columns)
plot(grad ? na : rising_bear,"Rising Bear",#ff1100,style=plot.style_columns)
plot(grad ? na : declining_bull,"Declining Bull",#2157f3,style=plot.style_columns)
plot(grad ? na : declining_bear,"Declining Bear",#ff1100,style=plot.style_columns)
//----
plot(grad ? rising_bull : na,"Rising Bull",gradient(min(rising_bull/a,1),1),style=plot.style_columns,editable=false)
plot(grad ? rising_bear : na,"Rising Bear",gradient(min(rising_bear/a,1),0),style=plot.style_columns,editable=false)
plot(grad ? declining_bull : na,"Declining Bull",gradient(min(declining_bull/b,1),1),style=plot.style_columns,editable=false)
plot(grad ? declining_bear : na,"Declining Bear",gradient(min(declining_bear/b,1),0),style=plot.style_columns,editable=false)
//----
plot(a,"Upper",#787b86),plot(b,"Lower",#787b86)