本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0
// at https://mozilla.org/MPL/2.0/
// © OngeanLogic
//@version=6
indicator(
title = "Voltex",
shorttitle = "Voltex",
overlay = false,
precision = 1)
// ============================================================================
// INPUT
// ============================================================================
lookback = input.int(
14,
"Volume Lookback",
minval = 1,
maxval = 500,
tooltip = "Number of chart candles used to calculate classified "
+ "buy and sell volume shares. "
+ "The two shares sum to 100%. "
+ "These show relative volume balance, not total activity. "
+ "Missing footprint data or an incomplete window produces gaps.")
// ============================================================================
// FOOTPRINT DATA
// ============================================================================
footprint barFootprint = request.footprint(100, 70)
float buyVolume = na
float sellVolume = na
if not na(barFootprint)
buyVolume := barFootprint.buy_volume()
sellVolume := barFootprint.sell_volume()
bool validBar = not na(buyVolume) and not na(sellVolume)
// ============================================================================
// ROLLING VOLUME SHARES
// ============================================================================
float availableBars = math.sum(
validBar ? 1.0 : 0.0,
lookback)
float rollingBuy = math.sum(
nz(buyVolume, 0.0),
lookback)
float rollingSell = math.sum(
nz(sellVolume, 0.0),
lookback)
float rollingTotal = rollingBuy + rollingSell
bool completeWindow = not na(availableBars) and
availableBars == lookback
bool ready = completeWindow and
not na(rollingTotal) and
rollingTotal > 0.0
float buyShare = ready ?
100.0 * rollingBuy / rollingTotal : na
float sellShare = ready ?
100.0 * rollingSell / rollingTotal : na
// ============================================================================
// REFERENCE LEVELS — CUSTOMISABLE IN STYLE
// ============================================================================
hline(
80,
"80% Reference",
color = color.new(color.gray, 55),
linestyle = hline.style_dotted)
hline(
20,
"20% Reference",
color = color.new(color.gray, 55),
linestyle = hline.style_dotted)
// ============================================================================
// TWO LINES — CUSTOMISABLE IN STYLE
// ============================================================================
plot(
buyShare,
title = "Buy Share %",
color = color.new(#19E72A, 25),
linewidth = 1,
style = plot.style_linebr)
plot(
sellShare,
title = "Sell Share %",
color = color.new(#EB0918, 25),
linewidth = 1,
style = plot.style_linebr)