TradingView脚本第3行报错:找不到'indicator'函数的技术问询
Pine Script v5 编译错误修复方案
问题根源
- Pine Script v5 已废弃
study()函数,所有脚本必须使用indicator()作为唯一的入口声明函数 - 你的脚本同时调用了
indicator()和已失效的study(),导致编译器无法识别study(),进而触发报错
修复步骤
- 删除第3行的
study("Support Resistance Channels", "sr_channels", overlay = true, max_bars_back = 501)语句 - 将
study()中的配置参数合并到第2行的indicator()中,确保脚本声明符合v5规范
修复后的代码片段
//@version=5 indicator("Support Resistance Channels", "sr_channels", overlay = true, max_bars_back = 501) // Input parameters prd = input(defval = 10, title="Pivot Period", minval = 4, maxval = 30, group = "Settings 🔨", tooltip="Used while calculating Pivot Points, checks left&right bars") ppsrc = input(defval = 'High/Low', title="Source", options = ['High/Low', 'Close/Open'], group = "Settings 🔨", tooltip="Source for Pivot Points") ChannelW = input(defval = 5, title = "Maximum Channel Width %", minval = 1, maxval = 8, group = "Settings 🔨", tooltip="Calculated using Highest/Lowest levels in 300 bars") minstrength = input(defval = 1, title = "Minimum Strength", minval = 1, group = "Settings 🔨", tooltip = "Channel must contain at least 2 Pivot Points") maxnumsr = input(defval = 6, title = "Maximum Number of S/R", minval = 1, maxval = 10, group = "Settings 🔨", tooltip = "Maximum number of Support/Resistance Channels to Show") - 1 loopback = input(defval = 290, title = "Loopback Period", minval = 100, maxval = 400, group = "Settings 🔨", tooltip="While calculating S/R levels it checks Pivots in Loopback Period") res_col = input(defval = color.new(color.red, 75), title = "Resistance Color", group = "Colors 🟡🟢🟣") sup_col = input(defval = color.new(color.lime, 75), title = "Support Color", group = "Colors 🟡🟢🟣") inch_col = input(defval = color.new(color.gray, 75), title = "Color When Price in Channel", group = "Colors 🟡🟢🟣") showpp = input(defval = false, title = "Show Pivot Points", group = "Extras ⏶⏷") showsrbroken = input(defval = false, title = "Show Broken Support/Resistance", group = "Extras ⏶⏷") showthema1en = input(defval = false, title = "MA 1", inline = "ma1") showthema1len = input(defval = 50, title = "", inline = "ma1") showthema1type = input(defval = "SMA", title = "", options = ["SMA", "EMA"], inline = "ma1") showthema2en = input(defval = false, title = "MA 2", inline = "ma2") showthema2len = input(defval = 200, title = "", inline = "ma2") showthema2type = input(defval = "SMA", title = "", options = ["SMA", "EMA"], inline = "ma2") // Calculate moving
内容的提问来源于stack exchange,提问作者illegally Browned
相关产品推荐
相关产品推荐

