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)
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.