You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pine Script通过高周期RSI过滤15分钟图买卖信号咨询

功能可行性结论

该需求可直接实现。Pine Script内置的跨周期数据调用函数可以在15分钟图表上直接获取4小时、8小时周期的行情数据并计算对应RSI指标,作为信号过滤条件,不需要手动切换图表周期。

修改要点
  • 新增RSI参数、阈值的可视化输入项,后续调整参数无需修改代码逻辑
  • 通过跨周期函数分别获取4小时、8小时周期的RSI计算值
  • 给原有买卖信号增加过滤规则:仅当4小时周期RSI大于45、8小时周期RSI小于60两个条件同时满足时,才会输出最终的买入、卖出信号
  • 修复了原代码中EMA参数定义行多余逗号的语法问题,避免脚本运行报错
修改后完整代码
study(title="8EMA 多周期RSI过滤版", shorttitle="8EMA_filtered", overlay = true)

// EMA参数
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")

// 多周期RSI过滤参数
rsi_len = input(14, minval=1, title="RSI计算周期")
rsi_4h_min = input(45, title="4小时RSI最低阈值")
rsi_8h_max = input(60, title="8小时RSI最高阈值")

// 绘制EMA线
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)

// 计算跨周期RSI
rsi_4h = request.security(syminfo.tickerid, "240", rsi(close, rsi_len))
rsi_8h = request.security(syminfo.tickerid, "480", rsi(close, rsi_len))
mtf_filter = rsi_4h > rsi_4h_min and rsi_8h < rsi_8h_max

// 原脚本枢轴点信号逻辑
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])

// 反向信号过滤
se_filtered = se and not le
le_filtered = le and not se

// 连续同向信号过滤
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]

// 最终信号增加多周期RSI过滤
se_final = se_filtered and prev[1] == -1 and mtf_filter
le_final = le_filtered and prev[1] == 1 and mtf_filter

// 绘制信号标记
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", "")
使用说明
  • 将脚本加载到15分钟周期图表上即可自动生效,跨周期RSI计算会在后台自动完成,不需要手动切换4小时、8小时图表
  • 所有参数都可以在脚本设置面板调整,包括EMA周期、RSI阈值、枢轴点判定的左右K线数量

内容的提问来源于stack exchange,提问作者trv202222

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.01 02:36:23