什么是“语法错误:不支持数组类型的变量!”在 PineScript 中真的是什么意思?

问题描述 投票:0回答:0

我为 PineScript 编写的代码中有一个我无法弄清楚的错误。

代码如下:

//@version=4
strategy(title="Test22", overlay=true)

// Define the indicators
fast_MA = sma(close, 10)
slow_MA = sma(close, 30)
rsi = rsi(close, 14)
macd = macd(close, 12, 26, 9)

// Define the strategy
longCondition = (fast_MA > slow_MA) and (rsi > 50) and (macd > 0)
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = (fast_MA < slow_MA) and (rsi < 50) and (macd < 0)
if (shortCondition)
    strategy.entry("Short", strategy.short)

strategy.exit("Exit", "Long", profit=0.05, loss=0.03)
strategy.exit("Exit", "Short", profit=0.05, loss=0.03)

// Plot the indicators on the chart
plot(fast_MA, color=color.blue)
plot(slow_MA, color=color.red)
plot(rsi, color=color.orange)
plot(macd, color=color.purple)

我收到这样的错误:

(Error at 11:0)语法错误:不支持数组类型的变量!

我试着运行我朋友发给我的代码,但它不工作。

pine-script pine-script-v4
© www.soinside.com 2019 - 2024. All rights reserved.