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

如何在当前时间框架下计算并同图绘制更低时间框架的RSI?

解决方法

直接对request.security_lower_tf返回的RSI数组计算平均值,再用plot函数绘制即可,具体实现如下:

完整代码示例

//@version=5
indicator("双周期RSI同图展示", overlay=false)

// 当前时间框架RSI
current_rsi = ta.rsi(close, 14)
plot(current_rsi, color=color.blue, title="当前周期RSI")

// 更低时间框架(60分钟)RSI数组,并计算平均值
lower_tf_rsi_array = request.security_lower_tf(syminfo.tickerid, "60", ta.rsi(close, 14))
lower_tf_rsi_avg = ta.mean(lower_tf_rsi_array)

// 绘制低周期RSI平均值
plot(lower_tf_rsi_avg, color=color.red, title="60分钟RSI平均值", style=plot.style_circles)

关键说明

  • ta.mean(lower_tf_rsi_array):直接对低周期RSI数组计算算术平均值,得到当前K线对应的低周期RSI平均数值
  • 通过设置不同color和style可以区分两条曲线,方便观察对比
  • 如果需要其他统计值(比如中位数、最大值),可以替换ta.mean为ta.median、ta.highest等对应函数

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 09:59:53