【问题标题】:Pine Script - How to get the high of current day, till current barPine Script - 如何获得当天的最高价,直到当前柱
【发布时间】:2021-06-15 19:33:14
【问题描述】:

我想得到当天的高值。高值应取自当天的前几根柱线。

我试过这个代码

security(syminfo.ticker, "D", high, lookahead=barmerge.lookahead_on)

但问题是它在当天的所有蜡烛之后取当天的高值。

谢谢。

【问题讨论】:

    标签: pine-script algorithmic-trading trading


    【解决方案1】:
    newDay = change(time("D")) != 0
    
    float todaysHigh = na
    
    if newDay
        todaysHigh := high
    else if high > todaysHigh[1]
        todaysHigh := high
    else
        todaysHigh := todaysHigh[1]
    

    if 块也可以写成三进制:

    todaysHigh := newDay ? high : high > todaysHigh[1] ? high : todaysHigh[1]
    

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 2021-11-08
      相关资源
      最近更新 更多