【问题标题】:Marking the highest high of each day (in a 24 h period only marking the highest bar)标记每天的最高点(在 24 小时内仅标记最高柱)
【发布时间】:2020-12-04 02:27:21
【问题描述】:

我只需要帮助标记每天的最高条。

我想出的这段代码标记了最高和最低的柱,但仅在最近一天。关于如何更改代码以标记每天的最高和最低条的任何想法?

使用最高(high,bars) 将返回所有最高柱的值。

对不起,如果我在错误的标签中发布了这个,它不会让我使用 pinescript 标签因为我是新用户请任何人都可以将标签上的标签更改为 pinescript

study("NewDay", overlay = true)

YY = year(time)
MM = month(time)
DD = dayofmonth(time)
Date = timestamp(YY, MM, DD, 0, 0)

newDay = (Date != Date[1])
bars = int(1440/timeframe.multiplier)

c = barssince(newDay) >= 0 and (barssince(newDay) < bars)

hb = c ? highestbars(high,bars) : na
lb = c ? lowestbars(low,bars) : na

// plot(Date)
bgcolor(newDay? color.gray : na , transp = 80)
bgcolor(color.red, offset = hb,show_last = 1, transp = 70)
bgcolor(color.green,offset = lb, show_last = 1, transp = 70)


【问题讨论】:

    标签: pine-script


    【解决方案1】:

    这将标记高/低柱。
    请注意,我排除了今天与isHist 的会话,因为不知道哪个是活动会话的最高/最低柱。如果您将今天的会话包括在内,您会看到脚本标记了每根柱线,该柱线形成了新的高点/低点。

    //@version=4
    study("Color highest bar", overlay = true)
    
    newSession = change(time('D'))
    
    [lo,hi] = security(syminfo.tickerid, 'D', [low,high], lookahead=barmerge.lookahead_on)
    
    isToday = (year == year(timenow)) and (month == month(timenow)) and (dayofmonth == dayofmonth(timenow))
    isHist  = not isToday
    
    lobar   = lo == low
    hibar   = hi == high
    
    bgcolor(newSession       ? color.white  : na, transp = 75)
    bgcolor(lobar and isHist ? color.red    : na, transp = 75)
    bgcolor(hibar and isHist ? color.green  : na, transp = 75)
    

    【讨论】:

    • 哇,非常感谢。你的代码很简单,工作得很好,我也从中学到了。非常感谢您花时间解决这个问题!!该死的,我让它变得如此复杂:D
    猜你喜欢
    • 2012-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多