使用更高的时间范围RSI过滤警报

发布于 2025-02-05 15:32:50 字数 1937 浏览 3 评论 0 原文

我试图弄清楚是否有可能使用现有的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", "")```

I'm trying to figure out if it's possible to do something with an existing pine script.

Using the 15 minute chart, I want the buy/sell signals to generate only when the 4 hour RSI is above 45 and the 8 hour RSI is below 60.

Is this possible?

Thanks in advance for any help :)

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⊕婉儿 2025-02-12 15:32:51

您可以使用功能。

//@version=5
indicator("request.security")
expr = ta.rsi(close, 14)
s1 = request.security(syminfo.tickerid, "240", expr) // 240 Minutes
plot(s1)

You can request data from other timeframes using the security() function.

//@version=5
indicator("request.security")
expr = ta.rsi(close, 14)
s1 = request.security(syminfo.tickerid, "240", expr) // 240 Minutes
plot(s1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文