簡體   English   中英

pine 腳本 v4:會話范圍問題

[英]pine script v4 : session range issue

我正在使用tradingview的原始源代碼學習松樹腳本和會話: 會話和時間信息

//@version=4
study("Opening high/low", overlay=true)
highTimeFrame = input("D", type=input.resolution)
sessSpec = input("0930-1600", type=input.session)
//---
is_newbar(res, sess) =>
   t = time(res, sess)
   na(t[1]) and not na(t) or t[1] < t
//---
newbar = is_newbar("1440", sessSpec)
//---
var float s1 = na
var float s2 = na
//---
if newbar
s1 := low
s2 := high
//---
plot(s1, style=plot.style_circles, linewidth=3, color=color.red)
plot(s2, style=plot.style_circles, linewidth=3, color=color.lime)

問題是它沒有顯示所有會話的范圍; 無論時間范圍如何,它都只顯示第一個柱的范圍。

我需要所有會話的范圍。 請問我該如何解決。

問候。

@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)

編輯:此處的級別選項圖片錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM