【发布时间】:2021-12-04 20:07:50
【问题描述】:
我正在对 TradingView 前一天的高点、低点和中点进行 OHLC 研究。我正在尝试添加类似于水平线文本功能的标签/文本。我在下面附上了两张图片作为我想要实现的示例。
代码如下:
h = security(syminfo.tickerid,"D",high,barmerge.gaps_off,barmerge.lookahead_on)
m = security(syminfo.tickerid,"D",hl2,barmerge.gaps_off,barmerge.lookahead_on)
p = security(syminfo.tickerid,"D",hlc3,barmerge.gaps_off,barmerge.lookahead_on)
l = security(syminfo.tickerid,"D",low,barmerge.gaps_off,barmerge.lookahead_on)
plotshape(series = condition and PrevBars ? h[1] : na, title = "Previous high",color = na,location=location.absolute ,editable = true)
plotshape(series = condition and PrevBars ? m[1] : na, title = "Previous median",color = na,location=location.absolute ,editable = true)
plotshape(series = condition and PrevBars ? p[1] : na, title = "Previous pivot",color = na,location=location.absolute ,editable = true)
plotshape(series = condition and PrevBars ? l[1] : na, title = "Previous low",color = na ,location = location.absolute , editable = true)
// Draw lines from the previous highs and lows
newSession = change(time('D'))
count = barssince(newSession)
var line PrevHigh = na
var line PrevMedian = na
var line PrevPivot = na
var line PrevLow = na
if (newSession)
PrevHigh := line.new(x1=bar_index, y1=h[1],
x2=bar_index, y2=h[1], color = color.green,width=1)
PrevMedian := line.new(x1=bar_index, y1=m[1],
x2=bar_index, y2=m[1], color = color.yellow,width=1)
PrevPivot := line.new(x1=bar_index, y1=p[1],
x2=bar_index, y2=p[1], color=color.orange,width=1)
PrevLow := line.new(x1=bar_index,y1=l[1],
x2=bar_index,y2=l[1],color = color.red,width = 1)
line.delete(id = PrevHigh[1])
line.delete(id = PrevMedian[1])
line.delete(id = PrevPivot[1])
line.delete(id = PrevLow[1])
if (not barstate.islast)
line.set_x2(id= PrevHigh, x=bar_index)
line.set_x2(id= PrevMedian, x=bar_index)
line.set_x2(id= PrevPivot, x=bar_index)
line.set_x2(id= PrevLow, x=bar_index)
else
line.set_xloc(id=PrevHigh, x1=time[count + 1],
x2=time_close + (1 * 86400000), xloc=xloc.bar_time)
line.set_xloc(id=PrevMedian, x1=time[count + 1],
x2=time_close + (1 * 86400000), xloc=xloc.bar_time)
line.set_xloc(id=PrevPivot, x1=time[count + 1],
x2=time_close + (1 * 86400000), xloc=xloc.bar_time)
line.set_xloc(id=PrevLow, x1=time[count + 1],
x2=time_close + (1 * 86400000), xloc=xloc.bar_time)
【问题讨论】:
标签: pine-script