Pinescript Elif功能

发布于 2025-02-13 15:51:54 字数 316 浏览 1 评论 0原文

我尝试在Pinescript中创建一个ELIF语句,但这是错误的。有人可以帮忙吗?

trend_1 = sma(close, 60)
trend_2 = sma(close, 30)
trend_3 = sma(close, 15)

if bar_index >= 252
    trend := trend_1
else if bar_index < 252 and >= 126
    trend := trend_2
else 
    trend := trend_3

不匹配的输入“如果“期望”线路结束而没有线路延续”。

I tried creating an elif statement in Pinescript but it came out as error. Can anyone please help?

trend_1 = sma(close, 60)
trend_2 = sma(close, 30)
trend_3 = sma(close, 15)

if bar_index >= 252
    trend := trend_1
else if bar_index < 252 and >= 126
    trend := trend_2
else 
    trend := trend_3

Mismatched input 'if' expecting 'end of line without line continuation'.

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

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

发布评论

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

评论(1

紫南 2025-02-20 15:51:54

错误是误导的。您忘了为&gt; =运算符提供左参数:

else如果bar_index&lt; 252 and&gt; = 126

在那里添加另一个bar_index,它应该有效:

else如果bar_index&lt; 252和bar_index&gt; = 126

The error is misleading. You forgot to supply the left argument for the >= operator:

else if bar_index < 252 and >= 126

Add another bar_index there and it should work:

else if bar_index < 252 and bar_index >= 126

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