Pine Script(TradingView)获得下一个会话详细信息

时间:2020-04-04 14:58:33

标签: pine-script

使用Pine Script,我可以使用以下代码绘制一条自定义行。

l = line.new(timestamp(2020, 04, 07, 09, 15), 17500, timestamp(2020, 04, 08, 09, 15), 17500, xloc.bar_time)
line.delete(l[1])

我想在下一个交易日上绘制一条自定义线(如下图所示)。

有没有办法在Pine Script中找到即将到来的交易日的时间戳?

enter image description here

1 个答案:

答案 0 :(得分:1)

这将适用于24/7市场。当您可以在实时市场上进行测试时,您可能需要进行调整:

//@version=4
study("", "", true)
y  = high
x1 = timestamp(year(timenow), month(timenow), dayofmonth(timenow) + 1, 9, 30)
x2 = timestamp(year(timenow), month(timenow), dayofmonth(timenow) + 2, 9, 30)
var line l = na
if barstate.islast
    if na(l)
        // Only create line once, then update it.
        l := line.new(x1, y, x2, y, xloc.bar_time)
        // Make 2 if blocks same type so compiler doesn't complain.
        int(na)
    else
        line.set_xy1(l, x1, y)
        line.set_xy2(l, x2, y)
        int(na)

enter image description here