Baekdoo ANGN
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © traderbaekdoosan

//@version=4
//ANGN
study(title="Baekdoo ANGN", overlay=true, scale=scale.left)
OLratio=abs((open-low)/(high-low))
HCratio=abs((high-close)/(high-low))
LCratio=abs((close-low)/(high-low))
HOratio=abs((high-open)/(high-low))

PV_ANGN=if close>open
    volume*(-HCratio) + volume - volume*OLratio
else 
    volume*LCratio + volume - volume*HOratio
    
NV_ANGN=if close<open
    volume*LCratio - volume + volume*HOratio
else
    volume*(-HCratio) - volume + volume*OLratio

ANGN_volume=if close>=close[1]
    PV_ANGN
else
    NV_ANGN
    
Cumulative_volume=sum(ANGN_volume/10, 500)
    
plot(Cumulative_volume, color=color.white)

//market cap
Outstanding = financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
MarketCap = Outstanding*close
//positive volume
//chunk=1500000000
VolumeRatio=input(1)
chunk=MarketCap/100*VolumeRatio

pAA=close>close[1]
pBB=ohlc4*volume>chunk
pv=0.0
if pAA and pBB
    pv:=volume
else
    pv:=0
    
//negative volume
nAA=close<close[1]
nBB=ohlc4*volume>chunk
nv=0.0
if nAA and nBB
    nv:=volume
else
    nv:=0
    
plot(pv, color=color.red, style=plot.style_columns)
plot(nv, color=color.blue, style=plot.style_columns)