本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Crypto Candle & Volume Buy Signal", shorttitle="CV Buy Signal", overlay=true)
// ─────────────────────────────
// Inputs
// ─────────────────────────────
length = input.int(20, "Average Period", minval=1)
rangeMult = input.float(1.5, "Range Multiplier", minval=0.1, step=0.1)
volumeMult = input.float(1.5, "Volume Multiplier", minval=0.1, step=0.1)
bodyRatio = input.float(60.0, "Minimum Body Ratio (%)", minval=1, maxval=100, step=5)
confirmedOnly = input.bool(true, "Signal on Candle Close Only")
// ─────────────────────────────
// Candle calculations
// ─────────────────────────────
candleRange = high - low
candleBody = math.abs(close - open)
bodyPercent = candleRange > 0 ? candleBody / candleRange * 100 : 0.0
// Previous 20 completed candles
avgRange = ta.sma(candleRange, length)[1]
avgVolume = ta.sma(volume, length)[1]
// ─────────────────────────────
// Buy conditions
// ─────────────────────────────
rangeOK = not na(avgRange) and candleRange >= avgRange * rangeMult
volumeOK = not na(avgVolume) and volume >= avgVolume * volumeMult
bodyOK = bodyPercent >= bodyRatio
bullishOK = close > open
candleOK = not confirmedOnly or barstate.isconfirmed
buySignal = rangeOK and volumeOK and bodyOK and bullishOK and candleOK
// ─────────────────────────────
// Buy arrow
// ─────────────────────────────
plotshape(
buySignal,
title="BUY",
style=shape.triangleup,
location=location.belowbar,
color=color.lime,
size=size.small,
text="BUY",
textcolor=color.lime
)
// ─────────────────────────────
// Alert
// ─────────────────────────────
alertcondition(
buySignal,
title="BUY Signal",
message="Crypto Candle & Volume BUY Signal: {{ticker}} | {{interval}}"
)