使用更高的时间范围RSI过滤警报
我试图弄清楚是否有可能使用现有的Pine脚本做某事。
使用15分钟的图表,我希望仅当4小时RSI超过45且8小时RSI低于60以下时,购买/出售信号才能产生。
这是否可能?
预先感谢您的任何帮助:)
study(title="8EMA", shorttitle="8EMA", overlay = true)
EMA1 = input(8, minval=1, title="EMA1")
EMA2 = input(13, minval=1, title="EMA2"),
EMA3 = input(21, minval=1, title="EMA3")
EMA4 = input(34, minval=1, title="EMA4"),
EMA5 = input(55, minval=1, title="EMA5")
EMA6 = input(89, minval=1, title="EMA6")
EMA7 = input(144, minval=1, title="EMA7")
EMA8 = input(233, minval=1, title="EMA8")
plot(ema(close, EMA1), color=green, linewidth=2)
plot(ema(close, EMA2), color=white, linewidth=2)
plot(ema(close, EMA3), color=gray, linewidth=2)
plot(ema(close, EMA4), color=blue, linewidth=2)
plot(ema(close, EMA5), color=red, linewidth=2)
plot(ema(close, EMA6), color=orange, linewidth=2)
plot(ema(close, EMA7), color=yellow, linewidth=2)
plot(ema(close, EMA8), color=purple, linewidth=2)
leftBars = input(4)
rightBars = input(2)
swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])
// Filter out signals if opposite signal is also on
se_filtered = se and not le
le_filtered = le and not se
// Filter consecutive entries
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]
se_final = se_filtered and prev[1] == -1
le_final = le_filtered and prev[1] == 1
plotshape(se_final, color=green, text = "BUY", style=shape.triangleup,location=location.belowbar)
plotshape(le_final, color=red, text = "SELL", style=shape.triangledown,location=location.abovebar)
alertcondition(se_final, "BUY-Autoview", "")
alertcondition(le_final, "SELL-Autoview", "")```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用功能。
You can request data from other timeframes using the security() function.