Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

//@version=5

// Original scripts are "The Lie Detector" by LucF and "Volume FLow v3" by oh92
// You need [Chart settings] → [Appearance] → [bottom margin] is set 0 %.
// volume density is volume divided by price. it means how many volume is used to
move price. large volume density means absorption by smart money.
// volume flow is value difference between bull MA(using vol which is larger than
previous vol and close > open) and bear MA(using vol which is larger than previous
vol and not close > open)

indicator("🔥🔥", overlay= true, scale= scale.none, max_labels_count= 1)

color decvolcandle = color.new(#000000FF,0)


color hivolupcandle = color.new(#0000FF, 0)
color hivoldncandle = color.new(#800080, 0)
color decvolbar = color.new(#000000FF,0)
color hivolupbar = color.new(#00897B, 0)
color hivoldnbar = color.new(#FF5252, 0)
int length = int(20)
bool useEma = bool(true )

float f = input.float(1.4, "Factor for Volume


Density ", inline= "00", group= "Volume Analysis", step= 0.1)
color vpclr = color.white//input.color(color.white, "",
inline= "00", group= "Volume Analysis")
// }

// ———————————————————— Global Date {


vol = volume
hl = high - low
vp = vol/hl // volume density
var float[] scaleMax = array.new_float() // not varip
// }

// ———————————————————— Functions {
// ----- Bar coloring cal (The Lie Detector)
upVol = ta.rising(vol, 1)
upBar = close > open

vMA = useEma ? ta.ema(vol, length) : ta.sma(vol, length)


volOverMa = vol > vMA // to decide Large volume

hollowBgdBlack = not upVol


upVolUpMaUpBar = upVol and volOverMa and upBar
upVolUpMaDnBar = upVol and volOverMa and not upBar

chollowBgdBlack = hollowBgdBlack ? decvolbar : na


cUpVolUpMaUpBar = upVolUpMaUpBar ? hivolupbar : na
cUpVolUpMaDnBar = upVolUpMaDnBar ? hivoldnbar : na
volumeclr = hollowBgdBlack ? color.new(open > close ? color.red : color.teal, 60) :
upBar ? upVolUpMaUpBar ? hivolupbar: color.new(hivolupbar, 0) : upVolUpMaDnBar ?
hivoldnbar : color.new(hivoldnbar, 0)

// ------ Volume Density Cal


vpMA = useEma ? ta.ema(vp, length) : ta.sma(vp, length) // use VolumeMAtype and
VolumeMA length
vpS = vp > vpMA * f and vp <= vpMA * f * f ? vol : na // small vp
vpL = vp > vpMA * f * f ? vol : na // large vp

// ------ Scale Adjustment Cal


array.push(scaleMax, vol)
if array.size(scaleMax) > length * 4
array.shift(scaleMax)

scalebase = array.max(scaleMax) // get max large volume


upperline = scalebase * 4 // max large volume become 1/4 position
// }

// ———————————————————— Outputs {

khollowBgdBlack = not upVol


kupVolUpMaUpBar = upVol and volOverMa and upBar
kupVolUpMaDnBar = upVol and volOverMa and not upBar

kchollowBgdBlack = khollowBgdBlack ? decvolcandle : na


kcUpVolUpMaUpBar = kupVolUpMaUpBar ? hivolupcandle : na
kcUpVolUpMaDnBar = kupVolUpMaDnBar ? hivoldncandle : na

barcolor(khollowBgdBlack ? kchollowBgdBlack : na, title= "Hollow candle(decreasing


volume/Not enough volume)")
barcolor(kupVolUpMaUpBar ? kcUpVolUpMaUpBar : na, title= "Up candle")
barcolor(kupVolUpMaDnBar ? kcUpVolUpMaDnBar : na, title= "Dn candle")

plot(vol, style= plot.style_columns, color= volumeclr, title= "Enough and Large


Volume")

// }

// ========================= Volume Flow ============================


float x = input.float(5, "Factor for Volume Spike ", inline= "02",
group= "Volume Analysis", step= 0.1)

// Bull and Bear Volume Cal


bull = upVol and upBar ? vol : 0 // not include decreasing upBar volume
bear = upVol and not upBar ? vol : 0 // not include decreasing upBar volume

//Bull and Bear MA Cal


bullma = useEma ? ta.ema(bull, length) : ta.sma(bull, length)
bearma = useEma ? ta.ema(bear, length) : ta.sma(bear, length)

// MA dif
vf_dif = bullma - bearma
vf_absolute = vf_dif > 0 ? vf_dif : vf_dif * (-1)

// Volume Spikes
gsig= ta.crossover(bull, bullma * x) ? vol : na
rsig = ta.crossover(bear, bearma * x) ? vol : na

// Plots
// plot(bullma*2, color=hivolup, linewidth=1, title="Bull MA")
// plot(bearma*2, color=hivoldn, linewidth=1, title="Bear MA")
plotchar(gsig, char= "🍏", color= hivolupcandle, location= location.absolute, title=
"Bull Vol Spike")
plotchar(rsig, char= "🍎", color= hivoldncandle, location= location.absolute, title=
"Bear Vol Spike")

// ================================================================

plotchar(vpS, char= "⬜", color= color.new(vpclr, 0), location= location.bottom,


title= "Volume Density(small,Absorption,Less potential reversal because volume
didnt move price)")
plotchar(vpL, char= "🟨", color= vpclr, location= location.bottom, title= "Volume
Density(large,Absorption,More potential reversal because volume didnt move price)")

plot(upperline, color= color(na), title= "Scale Adjustment")


// label = label.new(bar_index, 0, str.tostring(scale),
style=label.style_label_lower_left)
// label.delete(label[1])

//💥💥💥💥💥💥💥💥💥💥💥💥💥💥//
//💥💥💥💥💥💥💥💥💥💥💥💥💥💥//

You might also like