本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Stochastic 14, 3, 4", overlay=false)
// Settings
kLength = input.int(14, "%K Length")
kSmooth = input.int(3, "%K Smoothing")
dSmooth = input.int(4, "%D Smoothing")
// Stochastic calculation
rawK = ta.stoch(close, high, low, kLength)
k = ta.sma(rawK, kSmooth)
d = ta.sma(k, dSmooth)
// Levels
hline(80, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(50, "Middle", color=color.gray)
hline(20, "Oversold", color=color.green, linestyle=hline.style_dashed)
// Stochastic lines
plot(k, title="%K", color=color.blue, linewidth=2)
plot(d, title="%D", color=color.orange, linewidth=2)
// Crossover markers
plotshape(ta.crossover(k, d), title="Bullish Cross",
style=shape.circle, location=location.bottom,
color=color.green, size=size.tiny)
plotshape(ta.crossunder(k, d), title="Bearish Cross",
style=shape.circle, location=location.top,
color=color.red, size=size.tiny)