Pine script 在Pine编辑器中可能吗?

Pine script 在Pine编辑器中可能吗?,pine-script,Pine Script,我最近在tradingview的pine编辑器中创建了一个脚本 study("bota", overlay=true) t = time("240", session.extended) // 1440=60*24 is the number of minutes in a whole day is_first = na(t[1]) and not na(t) or t[1] < t apertura = na if is_first an

我最近在tradingview的pine编辑器中创建了一个脚本

study("bota", overlay=true)
 t = time("240", session.extended) // 1440=60*24 is the number of minutes in a whole day
is_first = na(t[1]) and not na(t) or t[1] < t


apertura = na


if is_first and barstate.isnew
    apertura := open
    
else
    apertura := apertura[1]
    

plot((apertura)+60, color=blue, linewidth=1, transp=20)
plot((apertura)-60, color=red, linewidth=1, transp=20)
study(“bota”,overlay=true)
t=时间(“240”,session.extended)//1440=60*24是一整天的分钟数
是_first=na(t[1]),而不是na(t)或t[1]
其中,执行时执行以下操作:

但我要找的是:


我对脚本的要求是,当四小时烛光开始时(utc),在这四小时结束前画两条线(无论图表的时间如何),不显示之前的烛光,并让这条线一直持续到结束,比初始价格高60美元(蓝线),比初始价格低60美元(红线)。查看一些论坛,但pine编辑器似乎会重新加载上面的所有蜡烛,并根据加载的蜡烛修改脚本。

这应该符合您的意图

//@version=4
// Credits for timeframe functions: https://www.tradingview.com/script/Wvcqygsx-MTF-Oscillator-Framework-PineCoders/
study("bota", overlay=true)

i_tf          = input("240",  "Timeframe for lines",                input.resolution)
i_offset_src  = input(open,   "Source to calculate offset from",    input.source)
i_offset      = input(60,     "Offset value",                       input.float)

var line    line_top = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.blue)
var line    line_src = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.gray, style=line.style_dotted)
var line    line_bot = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.red)

// ————— Converts current chart resolution into a float minutes value.
f_resInMinutes() => 
    _resInMinutes = timeframe.multiplier * (
      timeframe.isseconds ? 1. / 60             :
      timeframe.isminutes ? 1.                  :
      timeframe.isdaily   ? 60. * 24            :
      timeframe.isweekly  ? 60. * 24 * 7        :
      timeframe.ismonthly ? 60. * 24 * 30.4375  : na)

// ————— Returns resolution of _res string timeframe in minutes.
f_tfResInMinutes(_res) =>
    // _res: resolution of any TF (in `timeframe.period` string format).
    security(syminfo.tickerid, _res, f_resInMinutes())

var int tf_milliseconds = int(f_tfResInMinutes(i_tf) * 60 * 1000)
    
f_line_move(_line, _x, _y) => 
    line.set_xy1(_line, _x,                   _y)
    line.set_xy2(_line, _x + tf_milliseconds, _y)

[src,t] = security(syminfo.tickerid, i_tf, [i_offset_src,time], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)

if (barstate.islast)
    f_line_move(line_top, t, src + i_offset)
    f_line_move(line_src, t, src)
    f_line_move(line_bot, t, src - i_offset)

我真的不认为可以这样做,非常感谢你的贡献!!