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

TradingView Pine Script运行时报错找不到study函数是什么原因?

报错原因

你使用的是Pine Script v5运行环境,study是v4及更早版本的旧语法,v5版本已正式废弃该函数,因此触发找不到函数的报错。

修复方案

方案1:适配v5版本(推荐)

替换不兼容的语法即可正常运行,修复后的完整代码如下:

//@version=5
indicator("DeMark9 Indicator", overlay=true)
TD = close > close[4] ? nz(TD[1]) + 1 : 0
TS = close < close[4] ? nz(TS[1]) + 1 : 0
TDUp = TD - valuewhen(TD < TD[1], TD , 1 )
TDDn = TS - valuewhen(TS < TS[1], TS , 1 )
plotshape(TDUp==7 ? true : na, style=shape.triangledown, text="7", color=color.green, location=location.abovebar)
plotshape(TDUp==8 ? true : na, style=shape.triangledown, text="8", color=color.green, location=location.abovebar)
plotshape(TDUp==9 ? true : na, style=shape.triangledown, text="⚠️", color=color.green, location=location.abovebar)
plotshape(TDDn==7 ? true : na, style=shape.triangleup, text="7", color=color.red, location=location.belowbar)
plotshape(TDDn==8 ? true : na, style=shape.triangleup, text="8", color=color.red, location=location.belowbar)
plotshape(TDDn==9 ? true : na, style=shape.triangleup, text="✅", color=color.red, location=location.belowbar)

本次修改仅调整了3处不兼容语法,原有指标逻辑完全保留:

  • 头部新增//@version=5声明,指定用v5规则解析代码
  • 将study函数替换为v5标准的indicator函数
  • 颜色参数适配v5规范,避免不必要的运行警告

方案2:切换回旧版本运行

不需要修改代码,直接在TradingView编辑器右下角的版本选择下拉菜单中,将Pine Script运行版本切换为v4,即可直接运行原有代码。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 05:54:06