【问题标题】:How to get highest high, lowest low and close of a session in pine script tradingview如何在 pine script tradingview 中获得最高价、最低价和收盘价
【发布时间】:2021-10-20 10:30:12
【问题描述】:

我想获得特定时段的最高价和最低价以及收盘价。 任何人都可以知道这一点。

【问题讨论】:

    标签: pine-script


    【解决方案1】:

    使用以下代码:

    //@version=4
    //@author=LucF, for PineCoders
    study("Session hi/lo", "", true)
    noPlotOutside = input(true, "Don't plot outside of hours")
    showHi = input(true, "Show highs")
    showLo = input(true, "Show lows")
    srcHi = input(high, "Source for Highs")
    srcLo = input(low, "Source for Lows")
    timeAllowed = input("1200-1500", "Allowed hours", input.session)
    
    // Check to see if we are in allowed hours using session info on all 7 days of the week.
    timeIsAllowed = time(timeframe.period, timeAllowed + ":1234567")
    var hi = 10e-10
    var lo = 10e10
    if timeIsAllowed
        // We are entering allowed hours; reset hi/lo.
        if not timeIsAllowed[1]
            hi := srcHi
            lo := srcLo
        else
            // We are in allowed hours; track hi/lo.
            hi := max(srcHi, hi)
            lo := min(srcLo, lo)
    
    plot(showHi and not(noPlotOutside and not timeIsAllowed)? hi : na, "Highs", color.blue, 3, plot.style_circles)
    plot(showLo and not(noPlotOutside and not timeIsAllowed)? lo : na, "Lows", color.fuchsia, 3, plot.style_circles)
    

    https://www.pinecoders.com/faq_and_code/#how-can-i-track-highslows-for-a-specific-period-of-time

    【讨论】:

    • 谢谢@Starr Lucky,但您知道如何结束会话吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 2015-08-13
    相关资源
    最近更新 更多