【问题标题】:Operator logic wont work in PineScript / Tradingview操作员逻辑在 PineScript / Tradingview 中不起作用
【发布时间】:2020-05-12 11:33:07
【问题描述】:

我正在尝试在 tradingview 的 pine 脚本中创建一个显示 NEXT AUD 期货合约的脚本。我希望它能够计算出它是哪一年,然后将那一年添加到未来代码的末尾。

例如,今年 6 月 AUD 期货代码 = "6AM2020" 我可以参考这个,但几年后新的未来将是“6AM2021) 因此,为什么我希望脚本不断检查它是哪一年,然后在代码逻辑的末尾添加“找到的年份”。

但我不断收到此错误。

"脚本'TEST - Next AUD future' 已保存 处理脚本...

第 10 行:无法使用参数调用“运算符 +”(常量字符串,系列 [整数]);可用重载:+(const integer, const integer) => const integer; +(常量浮动,常量浮动)=>常量浮动; +(输入整数, 输入整数) => 输入整数; +(输入浮点数,输入浮点数)=> 输入浮点数; +(整数,整数)=>整数; +(浮动,浮动)=>浮动; +(系列[整数],系列[整数])=>系列[整数]; +(series[float], series[float]) => series[float]; +(常量字符串,常量字符串)=>常量字符串; +(输入字符串, 输入字符串) => 输入字符串; +(字符串,字符串)=>字符串; +(系列[字符串],系列[字符串])=>系列[字符串]; +(整数)=> 整数; +(浮动)=>浮动; +(输入整数)=> 输入整数; +(输入浮点数)=> 输入浮点数; +(常量整数)=>常量整数; +(常量浮动)=>常量浮动; +(系列[整数]) => 系列[整数]; +(系列[浮动]) => 系列[浮动]; 第 14 行:未声明的标识符“march_ticker”; 第 18 行:未声明的标识符 'march'

脚本“TEST - Next AUD Future”已保存“

代码-

//@version=4
study(title="Next AUD Future", overlay=true)


// References current bar year
ticker_year = year


// Builds the desired ticker using the correct year as above
june_ticker = ("CME" + ":" + "6AM" + ticker_year)


// Creates a series using the ticker thats built above
june = security(june_ticker, timeframe.period, close, barmerge.gaps_off, barmerge.lookahead_on)


// Plots the series above
plot(june, title="June", color=color.aqua, title='June', linewidth=1, transp=0)

代码-

非常感谢任何帮助。谢谢!

【问题讨论】:

  • 不要在多个论坛中问同一个问题。您冒着让不同的志愿者同时帮助您的风险。您的问题已在电视上的 Pine Script 聊天中得到解答。
  • @PineCoders-LucF。是的,谢谢你的帮助。我只是在发布此内容后才发现您的提要。将关闭此线程。

标签: operators operator-keyword pine-script


【解决方案1】:

@PineCoders-LucF 在他们的支持聊天中为任何感兴趣的人提供了这个解决方法。

//@version=4
study("")
r     = timeframe.period
v     = close
y     = year(timenow)
s2020 = security("CME:6AM2020", r, v)
s2021 = security("CME:6AM2021", r, v)
s2022 = security("CME:6AM2022", r, v)
s2023 = security("CME:6AM2023", r, v)
s2024 = security("CME:6AM2024", r, v)
s     = y == 2020 ? s2020 : y == 2021 ? s2021 : y == 2022 ? s2022 : y == 2023 ? s2023 : y == 2024 ? s2024 : na
plot(s)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多