本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sehweijun
// STOCH RSI CODE TAKEN FROM DEFAULT INDICATOR
// I HAVE ONLY MADE SOME ADJUSTMENTS FOR VISUAL AID
// I MADE THIS FOR MY OWN USE BUT HAVE DECIDED TO PUBLISH AND SHARE IN CASE ANYBODY WANTS TO USE IT
//@version=4
study(title="Stochastic RSI w/ Crossover Alerts (by WJ)", shorttitle="Stoch RSI (by WJ)", format=format.price, precision=2, resolution="")
smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
lengthRSI = input(14, "RSI Length", minval=1)
lengthStoch = input(8, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, "K", color=#0094FF, linewidth=2)
plot(d, "D", color=#FF6A00, linewidth=2)
h0 = hline(80, "Upper Band", color=#606060)
h1 = hline(20, "Lower Band", color=#606060)
h2 = hline(50, "Middle Band", color=#606060)
fill(h0, h1, color=#9915FF, transp=80, title="Background")
emaLen = input(200, minval=1, title="EMA")
ema = ema(close, emaLen)
crossupalert = open > ema and crossover(k,d) and k < 50
crossdownalert = open < ema and crossunder(k,d) and k > 50
bgcolor(color=crossupalert ? #4CAF50 : crossdownalert ? #FF0000 : na, transp=80, title="Crossover Alert Background Colour")
alertcondition( crossupalert or crossdownalert, title="Stoch RSI Crossover", message="STOCH RSI CROSSOVER")