REM ATTRIBUTABLE VOLUME
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capriole_charles
//@version=4
//study(“Attributable Volume”,overlay=false)
//freely adapted for the Prorealtime platform by bolsatrilera
type= volume//input(‘Attr-RVOL’,options=[‘Attr-RVOL’,’RVOL’,’Attr-Volume’,’Volume’])
trans=trans //en variables tipo boleano marcado verdad //input(true,’Plot Raw metric Transparently.’)
thresh=2.5//input(2.5,’RVOL Threshold’)
len =20// input(20,”RVOL Lookback Length”)
green = close>open
wickbottom = min(close,open)-low
wicktop = high – max(close,open)
solidlen = abs(close-open)
if attributablevolume = green then
attributablevolume = (volume * (solidlen+wickbottom)/(solidlen+wicktop+wickbottom))
else
attributablevolume =(volume * (solidlen+wicktop)/(solidlen+wicktop+wickbottom))
endif
rvol = volume/average [len](volume)
rvolattr = attributablevolume/average [len](attributablevolume)
if trans and type= volume then
t = rvol
elsif trans and type= volume then
t = volume
endif
if metric = type then
type =rvolattr
elsif type= rvol then
type = rvol
elsif type= volume then
type =attributablevolume
else
metric = volume
endif
if t = green then
r=255
g=0
b=0
else
r=0
g=128
b=0
endif
if metric = green then
r=255
g=0
b=0
else
r=0
g=128
b=0
endif
if type = volume or type = rvol then
type = thresh
endif
return t coloured(r,g,b)style(histogram)as”Raw”,metric coloured(r,g,b)style(histogram)as”Metric”,thresh coloured (128,128,128)as “Threshold”,0 coloured(128,128,128)as “0”