本页源码来自 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/
// © AstralVision
//@version=6
indicator("Stoch RSI Golden Cross | Astral Vision 🌠💠")
group4 = "Colors"
string theme = input.string("Inferno", "Color Theme", ["Inferno", "Paradiso", "Futura", "Infinito", "Hermes"], group = group4)
bool usecustom = input.bool(false, "Use Custom Colors", group = group4)
color custom_pos = input.color(color.rgb(255, 255, 255), "Custom Positive", group = group4)
color custom_neg = input.color(color.rgb(100, 100, 100), "Custom Negative", group = group4)
bool show = input.bool(true, "Show Only Bullish Golden Cross")
color theme_pos = theme == "Paradiso" ? color.rgb(0, 210, 255) : theme == "Futura" ? color.rgb(0, 255, 180) : theme == "Infinito" ? color.rgb(180, 120, 255) : theme == "Hermes" ? color.rgb(255, 160, 0) : color.rgb(255, 0, 0)
color theme_neg = theme == "Paradiso" ? color.rgb(0, 80, 160) : theme == "Futura" ? color.rgb(180, 0, 255) : theme == "Infinito" ? color.rgb(255, 220, 80) : theme == "Hermes" ? color.rgb(0, 180, 120) : color.rgb(120, 0, 0)
color col_bull = usecustom ? custom_pos : theme_pos
color col_bear = usecustom ? custom_neg : theme_neg
stoch_rsi() =>
rsi1 = ta.rsi(close, 121)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, 144), 33)
d = ta.sma(k, 25)
[k, d]
[k, d] = request.security(syminfo.tickerid, "5D", stoch_rsi())
plot(k, "K", color=col_bull)
plot(d, "D", color=col_bear)
plot(10, "Threshold Oversold", col_bull)
plot(80, "Threshold Overbought", col_bear)
turned_bull = k > d and k[1] < d[1] and k < 10
turned_bear = k < d and k[1] > d[1] and k > 80
if turned_bull
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bull, 0), width=3, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bull, 40), width=6, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bull, 65), width=12, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bull, 82), width=20, force_overlay=true)
if turned_bear and not show
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bear, 0), width=3, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bear, 40), width=6, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bear, 65), width=12, force_overlay=true)
line.new(bar_index, high * 1.5, bar_index, low * 0.5, xloc=xloc.bar_index, extend=extend.both, color=color.new(col_bear, 82), width=20, force_overlay=true)