本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// Author: CANSLIM Research
//@version=6
indicator("Last 25 Periods Volume Decline Count by CANSLIM Research", shorttitle="25D Vol Decline", overlay=true)
int length = input.int(25, title="Lookback Length", minval=1)
float atr = ta.atr(14)
// --- 1. Background Area ---
bool inLast25 = bar_index >= (last_bar_index - (length - 1))
bgcolor(inLast25 ? color.new(color.gray, 85) : na, title="Highlight Area")
// --- 2. Dynamic Line & Cumulative Counting ---
var line spanLine = line.new(na, na, na, na, color=color.gray, width=2)
var label[] activeLabels = array.new_label()
if barstate.islast
line.set_xy1(spanLine, bar_index - (length - 1), close)
line.set_xy2(spanLine, bar_index, close)
// Clear previous labels
if array.size(activeLabels) > 0
for i = 0 to array.size(activeLabels) - 1
label.delete(array.get(activeLabels, i))
array.clear(activeLabels)
// Loop through the last 25 bars
int declineCount = 0
for i = length - 1 to 0
if close[i] < close[i+1] and volume[i] > volume[i+1]
declineCount += 1
string displayText = declineCount >= 5 ? str.tostring(declineCount) + "\n💀" : str.tostring(declineCount)
// Apply colors directly to the text since the box is removed
color txtColor = declineCount >= 7 ? color.red :
declineCount == 6 ? color.orange :
declineCount == 5 ? color.yellow :
color.gray
// Use style_none to remove the background box for maximum thinness
lbl = label.new(x = bar_index[i],
y = high[i] + (atr[i] * 0.8),
text = displayText,
color = color.new(color.white, 100), // Transparent background
textcolor = txtColor,
style = label.style_none, // Removes the label bubble
size = size.normal) // Normal size reads best without a box
array.push(activeLabels, lbl)