Pine script 在未来价格中添加新的.line?

Pine script 在未来价格中添加新的.line?,pine-script,Pine Script,我花了一整天的时间想弄明白。。我来了 1. 我想制作一个脚本来绘制线条和文本,如下所示: 我算出了历史价格的线,但对于未来,我开始认为这是不可能的线?我已经试了很多了 2. 是否可以将文本直接放在line.new的垂直线上?或者制作一个新标签,并将其旋转90度 3. 我怎样才能使文本在横栏上/下处于同一水平?现在我使用low[30] /@version=4 研究(“试验编号032”,叠加=真实) fromHour=00 t1=时间戳(“GMT-4”,年,月,月,月,小时,00,00) t2=

我花了一整天的时间想弄明白。。我来了

1. 我想制作一个脚本来绘制线条和文本,如下所示:

我算出了历史价格的线,但对于未来,我开始认为这是不可能的线?我已经试了很多了

2. 是否可以将文本直接放在line.new的垂直线上?或者制作一个新标签,并将其旋转90度

3. 我怎样才能使文本在横栏上/下处于同一水平?现在我使用low[30]

/@version=4
研究(“试验编号032”,叠加=真实)
fromHour=00
t1=时间戳(“GMT-4”,年,月,月,月,小时,00,00)
t2=t1

timeIsOk=(time>=t1)和(time=t3)和(time这应该会让你走上正轨。如果你对代码有任何疑问,请提问

我们正在做的是保留两套线条和图纸:一套用于检测日常状况的酒吧,另一套用于未来,提前一周

文本不能在Pine中旋转,因此我们需要每行打印一个字母。文本在经过该行一个栏后打印,但当您放大/缩小时,其位置将相对于该行发生变化。对此我们无能为力

//@version=4
study("TEST nr 032",overlay=true)
fromHour = 00
t1 = timestamp("GMT-4", year, month, dayofmonth, fromHour, 00, 00)
t2 = t1
timeIsOk = (time >= t1) and (time <= t2)

// ————— Calculates the chart's normal time between bars.
f_chartTimeInterval() =>
    var _timeDelta = 10e15
    // Maintain the smallest interbar time value in the dataset, which should correspond to the chart's interval.
    _timeDelta := min(time - nz(time[1]), _timeDelta)

// ————— Calculates a time offset (+/-) which is a multiple of the chart's interval for use with drawing functions.
f_timeAtIntervalMultiple(_mult) =>
    // _mult ("series int"): +/- number of time intervals in the future/past to be calculated.
    int(time + f_chartTimeInterval() * _mult)

// ————— Calculates a +/- time offset from the current bar's time.
f_timeFromBar(_qty, _units) =>
    // _qty   : the +/- number of units of offset required. A "series float" can be used but it will cast to a "series int".
    // _units : string containing one of the 6 allowed time units (the `f_chartTimeUnits()` can be used to supply the current chart's resolution).
    _year   = year        + (_units == "years"   ? int(_qty) : 0)
    _month  = month       + (_units == "months"  ? int(_qty) : 0)
    _day    = dayofmonth  + (_units == "days"    ? int(_qty) : 0)
    _hour   = hour        + (_units == "hours"   ? int(_qty) : 0)
    _minute = minute      + (_units == "minutes" ? int(_qty) : 0)
    _second = second      + (_units == "seconds" ? int(_qty) : 0)
    timestamp(_year, _month, _day, _hour, _minute, _second)

// ————— Draws a text label.
f_drawText(_label, _x, _y, _t, _c) =>
    if na(_label)
        label.new(_x, _y, text = _t, xloc = xloc.bar_time, textcolor = _c, style = label.style_none)
    else
        label.set_xy(_label, _x, _y)
        _label

// ————— Draws a line.
f_drawLine(_line, _x, _c) =>
    if na(_line)
        line.new(_x, low * .9999, _x, high * 1.0001, xloc.bar_time, extend.both, _c, line.style_solid, 1)
    else
        line.set_xy1(_line, _x, low * .9999)
        line.set_xy2(_line, _x, high * 1.0001)
        _line

// ————— Processes one day of lines and labels.
f_doOneDay(_y, _day, _txtColor, _lineColor) =>
    timeInOneWeek = f_timeFromBar(7, "days")
    var line _lineCurrent = f_drawLine(line(na), time, _lineColor)
    var line _lineFuture  = f_drawLine(line(na), time, _lineColor)
    _lineCurrent := f_drawLine(_lineCurrent, time, _lineColor)
    _lineFuture  := f_drawLine(_lineFuture, timeInOneWeek, _lineColor)
    var label _labelCurrent = f_drawText(label(na), time, _y, _day, _txtColor)
    var label _labelFuture  = f_drawText(label(na), time, _y, _day, _txtColor)
    _labelCurrent := f_drawText(_labelCurrent, int(time + f_chartTimeInterval()), _y, _day, _txtColor)
    _labelFuture  := f_drawText(_labelFuture, int(timeInOneWeek + f_chartTimeInterval()), _y, _day, _txtColor)

y         = highest(close, 500)[1]
textColor = color.gray
lineColor = color.blue
txtMon    = "M\no\nn\nd\na\ny"
txtTue    = "T\nu\ne\ns\nd\na\ny"
txtWed    = "W\ne\nd\nn\ne\ns\nd\na\ny"
txtThu    = "T\nh\nu\nr\ns\nd\na\ny"
txtFri    = "F\nr\ni\nd\na\ny"
txtSun    = "S\nu\nn\nd\na\ny"

if timeIsOk and dayofweek == dayofweek.monday
    f_doOneDay(y, txtMon, textColor, lineColor)
else if timeIsOk and dayofweek == dayofweek.tuesday
    f_doOneDay(y, txtTue, textColor, lineColor)
else if timeIsOk and dayofweek == dayofweek.wednesday
    f_doOneDay(y, txtWed, textColor, lineColor)
else if timeIsOk and dayofweek == dayofweek.thursday
    f_doOneDay(y, txtThu, textColor, lineColor)
else if timeIsOk and dayofweek == dayofweek.friday
    f_doOneDay(y, txtFri, textColor, lineColor)

fromHour2 = 18
t3 = timestamp("GMT-4", year, month, dayofmonth, fromHour2, 00, 00)
t4 = t3
timeIsOk2 = (time >= t3) and (time <= t4)

if timeIsOk2 and dayofweek == dayofweek.sunday
    f_doOneDay(y, txtSun, color.red, color.red)
/@version=4
研究(“试验编号032”,叠加=真实)
fromHour=00
t1=时间戳(“GMT-4”,年,月,月,月,小时,00,00)
t2=t1
timeIsOk=(时间>=t1)和(时间
//数量:所需偏移单位的+/-数量。可以使用“系列浮点”,但它将转换为“系列整数”。
//_units:包含6个允许的时间单位之一的字符串(“f_chartTimeUnits()”可用于提供当前图表的分辨率)。
_年=年+(_单位==“年”?整数(_数量):0)
_月=月+(_单位==“月”?整数(_数量):0)
_day=dayofmonth+(_单位==“天”?整数(_数量):0)
_小时=小时+(_单位==“小时”?整数(_数量):0)
_分钟=分钟+(_单位==“分钟”?整数(_数量):0)
_秒=秒+(_单位==“秒”?整数(_数量):0)
时间戳(年、月、日、时、分、秒)
//-----绘制一个文本标签。
f_drawText(_标签,_x,_y,_t,_c)=>
如果na(_标签)
label.new(\ux,\uy,text=\uT,xloc=xloc.bar\u时间,textcolor=\uC,style=label.style\uNone)
其他的
label.set_xy(_label,_x,_y)
_标签
//----画一条线。
f_拉线(_线,_x,_c)=>
如果na(_线)
line.new(x,low*.9999,x,high*1.0001,xloc.bar\u时间,extend.both,c,line.style\u solid,1)
其他的
行。设置_xy1(_行,_x,低*.9999)
行。设置xy2(\u行,\u x,高*1.0001)
_线
//-----处理一天的线条和标签。
f_doOneDay(_y,_day,_txtColor,_lineColor)=>
timeInOneWeek=f_timebrombar(7,“天”)
var line _lineCurrent=f_绘制线(线(na)、时间、线颜色)
var line _lineFuture=f_绘制线(线(na)、时间、线颜色)
_lineCurrent:=f_绘制线(_lineCurrent,time,_lineColor)
_lineFuture:=f_绘图线(_lineFuture,timeinonewek,_lineColor)
var label\u labelCurrent=f\u drawText(标签(na)、时间、日期、颜色)
var label\u labelFuture=f\u drawText(标签(na)、时间、日期、颜色)
_labelCurrent:=f_drawText(_labelCurrent,int(time+f_chartTimeInterval()),_y,_day,_txtColor)
_labelFuture:=f_drawText(_labelFuture,int(timeInOneWeek+f_chartTimeInterval()),_y,_day,_txtColor)
y=最高(接近500)[1]
textColor=color.gray
lineColor=color.blue
txtMon=“M\no\nn\nd\na\ny”
txtTue=“T\nu\ne\ns\nd\na\ny”
txtwd=“W\ne\nd\nn\ne\ns\nd\na\ny”
txthu=“T\nh\nu\nr\ns\nd\na\ny”
txtFri=“F\nr\ni\nd\na\ny”
txtSun=“S\nu\nn\nd\na\ny”
如果timeIsOk和dayofweek==dayofweek.monday
f_doOneDay(y、txtMon、textColor、lineColor)
如果timeIsOk和dayofweek==dayofweek.周二
f_doOneDay(y、txtTue、textColor、lineColor)
如果timeIsOk和dayofweek==dayofweek.周三
f_doOneDay(y、txtWed、textColor、lineColor)
如果timeIsOk和dayofweek==dayofweek.周四,则为else
f_doOneDay(y、txtThu、textColor、lineColor)
如果timeIsOk和dayofweek==dayofweek.friday
f_doOneDay(y、txtFri、textColor、lineColor)
fromHour2=18
t3=时间戳(“GMT-4”,年、月、月、日,从小时2、00、00)
t4=t3
时间ISOK2=(时间>=t3)和(时间