字符串作为松树脚本中的函数参数

时间:2019-07-18 09:12:22

标签: pine-script

我无法使pine脚本接受字符串作为参数。它将其解释为unknown_type或函数参数类型,因此它会在input()上崩溃,因为defval需要字符串const。

试图将其作为变量传递,以“欺骗”解释器。 尝试进行以下比较,并使用更多(如果还有其他方法)组合和策略。

// Check the first 5 lines
rsi(timeframe_) =>
    timeframe = '60'
    if timeframe_ == '60'  
        timeframe := timeframe  
    src = security(tickerid, input(type=resolution, defval=timeframe) , close)
    len = input(defval=m_defvalRSI, minval=1, title="LengthRSI", type=integer)
    up = rma(max(change(src), 0), len)
    down = rma(-min(change(src), 0), len)

    rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
time_ = "D"
plot(rsi(time_), color=yellow)
```defval=type_unknown```
line 11: Cannot call `input` with arguments (type=const string, defval=type_unknown); available overloads: input(const bool, const string, const string, bool, const string) => bool; input(const integer, const string, const string, integer, integer, bool, integer, [const integer...], const string) => integer; input(const float, const string, const string, float, float, bool, float, [const float...], const string) => float; input(const string, const string, const string, bool, [const string...], const string) => string; input(series, const string, const string, const string) => series;

0 个答案:

没有答案