首页 > 解决方案 > 如何更正我在 line.new() 中的负索引?脚本

问题描述

//我的line.new函数有问题。我想要一条在 0830-1630 之间从接近到接近的线,所以可能是对角线......

_zoneSession = input(title = "Session", type = input.session, defval = "0830-1630:1234567")

_zoneInitialBalanceStop   = input(title = "Initial Balance Session", type = input.session, defval = "0930-0931:1234567")

_timeZone  = time(timeframe.period, _zoneSession)

_hLZone = time(timeframe.period,_zoneInitialBalanceStop)

_session_Start= plot(na(_timeZone)[1] == 1 and na(_timeZone) == 0 ? close : na, style = plot.style_histogram, linewidth = 3, color = color.green)

_session_Stop= plot(na(_timeZone)[1] == 0 and na(_timeZone) == 1 ? close : na, style = plot.style_histogram, linewidth = 3, color = color.green)

_session_bal_Stop= plot(na(_hLZone)[1] == 0 and na(_hLZone) == 1 ? close : na, style = plot.style_histogram, linewidth = 3, color = color.red)



_sessionSy1_condx1 = na(_timeZone)[1] == 1 and na(_timeZone) == 0 ? close : na
_sessionSy1_condx2 = na(_timeZone)[1] == 0 and na(_timeZone) == 1 ? close : na


//I HAVE PROBLEMS WITH THE LINE.NEW FUNCTION I WNAT A LINE FROM CLOSE TO CLOSE BTWN 0830-1630 so probably a diagonal...

line.new(timestamp(year,month,dayofmonth,08,30),_sessionSy1_condx1, timestamp(year,month,dayofmonth,16,30),_sessionSy1_condx2, xloc= xloc.bar_index, extend = extend.right)

标签: pine-scriptline-drawing

解决方案


为和使用时间值时需要xloc= xloc.bar_time在您的通话中使用。line.newx1=x2=


推荐阅读