Pine 脚本错误“输入‘符号’处的语法错误”

发布于 2025-01-13 19:46:57 字数 672 浏览 1 评论 0原文

我是 pinescript 的新手,我有一个交易视图的开源脚本。 但我正在努力解决语法错误,但尚未找到解决方案。

如果有人能帮助我解决这个问题,我将不胜感激。

输入“符号”时出现语法错误

//@version=4
study(title='Moving Average Cross', shorttitle='Moving Average Cross', overlay=true, precision=6, max_labels_count=500, max_lines_count=500)

f_ma(smoothing, [symbol=src]src[/symbol], length) =>
    iff(smoothing == "RMA",     rma([symbol=src]src[/symbol], length), 
    iff(smoothing == "SMA",    [__tag__=simplemovingaverage]sma[/__tag__] ([symbol=src]src[/symbol], length)),
    iff(smoothing == "EMA",    [__tag__=ema]ema[/__tag__] ([symbol=src]src[/symbol], length), [symbol=src]src[/symbol]))

I am new to pinescript and I have an open source script for tradingview.
But I'm struggling with a syntax error and haven't found a solution yet.

I would appreciate if someone could help me with this problem.

Syntax error at input 'symbol'

//@version=4
study(title='Moving Average Cross', shorttitle='Moving Average Cross', overlay=true, precision=6, max_labels_count=500, max_lines_count=500)

f_ma(smoothing, [symbol=src]src[/symbol], length) =>
    iff(smoothing == "RMA",     rma([symbol=src]src[/symbol], length), 
    iff(smoothing == "SMA",    [__tag__=simplemovingaverage]sma[/__tag__] ([symbol=src]src[/symbol], length)),
    iff(smoothing == "EMA",    [__tag__=ema]ema[/__tag__] ([symbol=src]src[/symbol], length), [symbol=src]src[/symbol]))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫尐诺 2025-01-20 19:46:57
  1. 这是带有 html 标签的错误 copypasta。

  2. iff 函数对于新手来说比较困难,请尝试使用 Pine V5 及其 switch 函数

//@version=5
indicator("My script")

string i_maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA", "WMA"])


f_ma(smoothing, src, length) =>
    float ma = switch smoothing
        "EMA" => ta.rma(src, length)
        "SMA" => ta.sma(src, length)
        "RMA" => ta.ema(src, length)
        // Default used when the three first cases do not match.
        => ta.wma(src, length)
    ma


s = f_ma(i_maType, close, 20)

plot(s)

这里是 V5 手册

  1. This is erroneous copypasta with html tags.

  2. iff function is hard for newbies, try using Pine V5 and its switch function:

//@version=5
indicator("My script")

string i_maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA", "WMA"])


f_ma(smoothing, src, length) =>
    float ma = switch smoothing
        "EMA" => ta.rma(src, length)
        "SMA" => ta.sma(src, length)
        "RMA" => ta.ema(src, length)
        // Default used when the three first cases do not match.
        => ta.wma(src, length)
    ma


s = f_ma(i_maType, close, 20)

plot(s)

here is V5 manual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文