pine-script - 第 102 行:不能用 'expr1'=input integer 调用 'operator =='。参数的类型应该是: const string;
问题描述
我收到以下代码的上述错误消息,但我不明白为什么,请帮忙。它用于 mtf 指标。参数是一个字符串,因为引号在那里。这真的很令人困惑。
有人可以帮忙吗?
res(Resolution) =>
if Resolution == "00 Current"
timeframe.period
else
if Resolution == "01 1m"
"1"
else
if Resolution == "02 3m"
"3"
else
if Resolution == "03 5m"
"5"
else
if Resolution == "04 15m"
"15"
else
if Resolution == "05 30m"
"30"
else
if Resolution == "06 45m"
"45"
else
if Resolution == "07 1h"
"60"
else
if Resolution == "08 2h"
"120"
else
if Resolution == "09 3h"
"180"
else
if Resolution == "10 4h"
"240"
else
if Resolution == "11 1D"
"1D"
else
if Resolution == "12 1W"
"1W"
else
if Resolution == "13 1M"
"1M"
解决方案
https://www.tradingview.com/pine-script-reference/v4/#op_==
似乎您在函数中传递了输入整数类型。您不能将整数与字符串进行比较。在 res() 调用中使用 tosting() 或 str.format() 函数解析数据。
x = input(01)
m = "1m"
res(tosting(x) + m)
推荐阅读
- url - 可以让 Firefoxe 的 web-ext 实用程序以 -u 开头打开扩展页面吗?
- asp.net-core - ASP.Net Core 2.1:通过路由传递 urlencoded “id”?
- django - 如何在不使用过滤器的情况下获取模型的多个对象?
- r - 将字符串中第 N 次出现的字符替换为其他字符
- c# - 如何解决多表单问题 (CS7036)
- react-native - 如何在 React Native 中使用酶测试 openDrawer?
- java - apache.commons.logging.log 性能没有调试日志代码保护
- java - 如何将两个活动制作到一个文件中?
- f# - f# 将 seq obj 转换为 seq 记录
- javascript - 使用 Content-Type 时 nodejs https 请求抛出错误