OPEN-SOURCE SCRIPT
Support Line: Max Buying Volume

//version=5
indicator("Support Line: Max Buying Volume", overlay=true)
// === INPUTS ===
length = input.int(100, title="Lookback Period")
priceResolution = input.float(0.5, title="Price Bin Size") // Granularity of price levels
lineColor = input.color(color.green, title="Support Line Color")
lineWidth = input.int(2, title="Line Width")
// === BINNING UTILITY ===
get_bin(price) =>
math.round(price / priceResolution) * priceResolution
// === DATA STRUCTURES ===
var float[] priceBins = array.new_float()
var float[] buyVolumeBins = array.new_float()
// === RESET DATA IF EXCEEDED LENGTH ===
if array.size(priceBins) > length
array.clear(priceBins)
array.clear(buyVolumeBins)
// === TRACK BUYING VOLUME ===
if close > open
bin = get_bin(close)
idx = array.indexof(priceBins, bin)
if idx == -1
array.push(priceBins, bin)
array.push(buyVolumeBins, volume)
else
oldVol = array.get(buyVolumeBins, idx)
array.set(buyVolumeBins, idx, oldVol + volume)
// === FIND MAX BUYING VOLUME BIN ===
var float supportPrice = na
maxVol = 0.0
for i = 0 to array.size(priceBins) - 1
vol = array.get(buyVolumeBins, i)
if vol > maxVol
maxVol := vol
supportPrice := array.get(priceBins, i)
// === DRAW SUPPORT LINE ===
var line supportLine = na
if not na(supportPrice)
if na(supportLine)
supportLine := line.new(x1=bar_index, y1=supportPrice, x2=bar_index + 1, y2=supportPrice, color=lineColor, width=lineWidth)
else
line.set_xy1(supportLine, bar_index, supportPrice)
line.set_xy2(supportLine, bar_index + 1, supportPrice)
indicator("Support Line: Max Buying Volume", overlay=true)
// === INPUTS ===
length = input.int(100, title="Lookback Period")
priceResolution = input.float(0.5, title="Price Bin Size") // Granularity of price levels
lineColor = input.color(color.green, title="Support Line Color")
lineWidth = input.int(2, title="Line Width")
// === BINNING UTILITY ===
get_bin(price) =>
math.round(price / priceResolution) * priceResolution
// === DATA STRUCTURES ===
var float[] priceBins = array.new_float()
var float[] buyVolumeBins = array.new_float()
// === RESET DATA IF EXCEEDED LENGTH ===
if array.size(priceBins) > length
array.clear(priceBins)
array.clear(buyVolumeBins)
// === TRACK BUYING VOLUME ===
if close > open
bin = get_bin(close)
idx = array.indexof(priceBins, bin)
if idx == -1
array.push(priceBins, bin)
array.push(buyVolumeBins, volume)
else
oldVol = array.get(buyVolumeBins, idx)
array.set(buyVolumeBins, idx, oldVol + volume)
// === FIND MAX BUYING VOLUME BIN ===
var float supportPrice = na
maxVol = 0.0
for i = 0 to array.size(priceBins) - 1
vol = array.get(buyVolumeBins, i)
if vol > maxVol
maxVol := vol
supportPrice := array.get(priceBins, i)
// === DRAW SUPPORT LINE ===
var line supportLine = na
if not na(supportPrice)
if na(supportLine)
supportLine := line.new(x1=bar_index, y1=supportPrice, x2=bar_index + 1, y2=supportPrice, color=lineColor, width=lineWidth)
else
line.set_xy1(supportLine, bar_index, supportPrice)
line.set_xy2(supportLine, bar_index + 1, supportPrice)
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。