找不到函数或函数引用 - 私有函数不是 found/recognized?松脚本
Could not find function or function reference - private function is not found/recognized? Pine Script
如果我从 tview 库中获取一些随机函数,例如kc (Keltner Channel) 并将其保存为我自己的脚本,例如 kc2,然后我无法将其作为策略 Pine Script 的一部分调用。然后它说:“找不到函数或函数引用”。我已确定呼叫(大写字母等是正确的)。我可以在我的脚本下找到该函数。那为什么策略Pine Script找不到函数呢?
它不能只是你的库的一部分,该函数的代码实际上需要包含在策略脚本本身中。
//@version=4
study("My Script", overlay = true)
// -----------------------------------------------------------------------------
// Keltner channel section
// -----------------------------------------------------------------------------
length = input(20, minval=1)
mult = input(1.0, "Multiplier")
src = input(close, title="Source")
exp = input(true, "Use Exponential MA")
BandsStyle = input("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style")
atrlength = input(10, "ATR Length")
esma(source, length)=>
s = sma(source, length)
e = ema(source, length)
exp ? e : s
ma = esma(src, length)
rangema = BandsStyle == "True Range" ? tr(true) : BandsStyle == "Average True Range" ? atr(atrlength) : rma(high - low, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
u = plot(upper, color=#2962FF, title="Upper")
plot(ma, color=#2962FF, title="Basis")
l = plot(lower, color=#2962FF, title="Lower")
fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background")
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Some other code using KC variables
longSignal = open < ma and close > ma
plotshape(longSignal, location = location.belowbar, style = shape.triangleup, color = color.lime)
如果我从 tview 库中获取一些随机函数,例如kc (Keltner Channel) 并将其保存为我自己的脚本,例如 kc2,然后我无法将其作为策略 Pine Script 的一部分调用。然后它说:“找不到函数或函数引用”。我已确定呼叫(大写字母等是正确的)。我可以在我的脚本下找到该函数。那为什么策略Pine Script找不到函数呢?
它不能只是你的库的一部分,该函数的代码实际上需要包含在策略脚本本身中。
//@version=4
study("My Script", overlay = true)
// -----------------------------------------------------------------------------
// Keltner channel section
// -----------------------------------------------------------------------------
length = input(20, minval=1)
mult = input(1.0, "Multiplier")
src = input(close, title="Source")
exp = input(true, "Use Exponential MA")
BandsStyle = input("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style")
atrlength = input(10, "ATR Length")
esma(source, length)=>
s = sma(source, length)
e = ema(source, length)
exp ? e : s
ma = esma(src, length)
rangema = BandsStyle == "True Range" ? tr(true) : BandsStyle == "Average True Range" ? atr(atrlength) : rma(high - low, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
u = plot(upper, color=#2962FF, title="Upper")
plot(ma, color=#2962FF, title="Basis")
l = plot(lower, color=#2962FF, title="Lower")
fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background")
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Some other code using KC variables
longSignal = open < ma and close > ma
plotshape(longSignal, location = location.belowbar, style = shape.triangleup, color = color.lime)