OPEN-SOURCE SCRIPT
CustVolumeStudy - Stacked Buy/Sell + Sell% (top-right)

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © ashley_fickett
//version=5
indicator("CustVolumeStudy - Stacked Buy/Sell + Sell% (top-right)", shorttitle="CustVolStack", overlay=false)
// Inputs
volSmaLen = input.int(50, "Volume SMA Length")
showSellPct = input.bool(true, "Show Current Bar Sell % (top-right)")
// Price/volume
H = high
L = low
C = close
V = volume
// Compute sell & buy volume (guard H != L)
sellVol = H != L ? V * (H - C) / (H - L) : 0.0
buyVol = H != L ? V * (C - L) / (H - L) : V
totalVol = buyVol + sellVol // should equal V
// ---------------------- Current bar Sell % (top-right table) ----------------------
sellPct = V > 0 ? math.round(sellVol / V * 100) : na
var table sellTbl = table.new(position.top_right, 1, 1, bgcolor = color.new(color.black, 60), frame_width = 1, frame_color = color.gray)
if barstate.islast
if showSellPct and not na(sellPct)
txt = "Cur Bar Sell %: " + str.tostring(sellPct) + "%"
bg = sellPct > 51 ? color.new(color.red, 0) : sellPct < 49 ? color.new(color.green, 0) : color.new(color.orange, 0)
table.cell(sellTbl, 0, 0, txt, text_color = color.white, bgcolor = bg, text_size = size.normal)
else
table.cell(sellTbl, 0, 0, "", text_color = color.white, bgcolor = color.new(color.black, 100))
// © ashley_fickett
//version=5
indicator("CustVolumeStudy - Stacked Buy/Sell + Sell% (top-right)", shorttitle="CustVolStack", overlay=false)
// Inputs
volSmaLen = input.int(50, "Volume SMA Length")
showSellPct = input.bool(true, "Show Current Bar Sell % (top-right)")
// Price/volume
H = high
L = low
C = close
V = volume
// Compute sell & buy volume (guard H != L)
sellVol = H != L ? V * (H - C) / (H - L) : 0.0
buyVol = H != L ? V * (C - L) / (H - L) : V
totalVol = buyVol + sellVol // should equal V
// ---------------------- Current bar Sell % (top-right table) ----------------------
sellPct = V > 0 ? math.round(sellVol / V * 100) : na
var table sellTbl = table.new(position.top_right, 1, 1, bgcolor = color.new(color.black, 60), frame_width = 1, frame_color = color.gray)
if barstate.islast
if showSellPct and not na(sellPct)
txt = "Cur Bar Sell %: " + str.tostring(sellPct) + "%"
bg = sellPct > 51 ? color.new(color.red, 0) : sellPct < 49 ? color.new(color.green, 0) : color.new(color.orange, 0)
table.cell(sellTbl, 0, 0, txt, text_color = color.white, bgcolor = bg, text_size = size.normal)
else
table.cell(sellTbl, 0, 0, "", text_color = color.white, bgcolor = color.new(color.black, 100))
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。