【问题标题】:How to Run a Conditional Statement in TradingView Pine-Script?如何在 TradingView Pine-Script 中运行条件语句?
【发布时间】:2019-01-16 07:58:41
【问题描述】:

查看 Pine-Script 文档后,我无法找到“Switch”样式的条件语句。

我试图仅从绿色蜡烛中减去开盘价和收盘价。

这是我当前的代码:

//@version=3 study(title="High Minus Low", shorttitle="HM0", overlay=true)

openall  = high[0]+high[1]+high[2]
closeall = open[0]+open[1]+open[2] total = openall + closeall

plot(total)

我只想使用条件语句获取最新的 3 个绿色蜡烛条。

这可能吗?

【问题讨论】:

  • 为什么不使用嵌套的 if 呢?

标签: python switch-statement conditional-statements pine-script


【解决方案1】:

PineScript 中没有“switch”语句。但是,您可以为您的任务使用“if”语句。例如

green_delta = 0.0
if close > open
    green_delta := open - close 
plot(green_delta)    

【讨论】:

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