本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Weak Candle Sequence (ATR Based)", overlay=true)
// === INPUTS ===
atrLength = input.int(14, "ATR Length")
threshold = input.float(0.10, "Max Body Size (% of ATR)", step=0.01)
minCandles = input.int(4, "Min Weak Candles in a Row", minval=1)
showLabels = input.bool(true, "Show Label")
// === CALCULATIONS ===
atrValue = ta.atr(atrLength)
// Candle body size
bodySize = math.abs(close - open)
// Weak candle condition
isWeak = bodySize <= (atrValue * threshold)
// Count consecutive weak candles
var int weakCount = 0
weakCount := isWeak ? weakCount + 1 : 0
// Condition met
sequenceMet = weakCount >= minCandles
// === VISUALS ===
// Highlight background
bgcolor(sequenceMet ? color.new(color.yellow, 85) : na)
// Optional label on first occurrence
plotshape(
sequenceMet and not sequenceMet[1],
title="Weak Sequence Start",
location=location.abovebar,
color=color.yellow,
style=shape.labeldown,
text="Weak Run"
)
// Plot weak candles (optional visual)
barcolor(isWeak ? color.gray : na)