松树脚本v4:会话范围问题

时间:2020-03-26 15:31:32

标签: session range pine-script

我正在使用pineview的原始源代码学习松树脚本和会话:Session and time information

Derived &operator=(Derived &&o) = default;

问题是它没有显示所有会话的范围;无论何时,它只会显示第一个柱的范围。

我需要所有会话的范围。 我该如何解决。

致谢。

1 个答案:

答案 0 :(得分:0)

@ PineCoders-LucF

我找到了你的来源。这正是我想要的 但是选项:squareBox = boxType ==“固定级别”错误。

源代码:

//@version=4
//@author=LucF, for PineCoders
study("Time Range", "", true)
sessionInfo = input("1100-1500", "Session")
boxType = input("Fixed levels", "Box Type", options = ["None", "Dynamic levels", "Fixed levels"])
showBg = input(false, "Show background")
squareBox = boxType == "Fixed levels"
dynamicBox = boxType == "Dynamic levels"
showBox = squareBox or dynamicBox

inSession = time(timeframe.period, sessionInfo)
invisible = #FFFFFF

loLevel = lowest(10)
hiLevel = highest(10)
var hi = 10e-10
var lo = 10e10
// When a new period begins, reset hi/lo.
if inSession and not inSession[1]
    hi := dynamicBox ? high : hiLevel
else
    if dynamicBox
        hi := max(high, hi)
if inSession and not inSession[1]
    lo := dynamicBox ? low : loLevel
else
    if dynamicBox
        lo := min(low, lo)

hiPlot = plot(showBox and inSession ? hi : na, "Highs", invisible)
loPlot = plot(showBox and inSession ? lo : na, "Lows", invisible)
fill(hiPlot, loPlot, color.navy)

// Plot background.
bgcolor(showBg and inSession ? color.blue : na)

编辑: Bug of levels option picture here