【发布时间】:2021-10-26 16:29:58
【问题描述】:
我正在使用 tradingview RSI 指标的原始源代码,我正在尝试对其进行调整,以便在 RSI 信号出现超买或超卖时向我发送警报。我觉得我快到了,但我错过了一些可以让我调整警报的东西?老实说,我不知道我错过了什么,我需要一些帮助来解决这个问题。
//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
//Get Values
len = input(10, minval=1, title="Length")
src = input(close, "Source", type = input.source)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
overbought = input(title="OB",defval=70)
oversold = input(title="OS",defval=30)
//RSI Value
rsiValue = rsi(src, len)
rsiOverbought = barstate.isconfirmed and crossunder(rsiValue, overbought)
rsiOversold = barstate.isconfirmed and crossover(rsiValue, oversold)
//Alerts
alertcondition(rsiOverbought, title = "Overbought", message = "{{close}}")
alertcondition(rsiOversold, title = "Oversold", message = "{{close}}")
// Plotted Values
plot(rsi, "RSI", color=#7E57C2)
band1 = hline(70, "Upper Band", color=#787B86)
bandm = hline(50, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(30, "Lower Band", color=#787B86)
fill(band1, band0, color=color.rgb(126, 87, 194, 90), title="Background")
任何帮助都会很棒,谢谢!
保罗
【问题讨论】:
标签: pine-script alerts