嗨,当枢轴交叉发生时,如何在柱线上方绘制显示收盘价的标签。当条形图收盘高于R1或前一日高点而条形收盘价低于S1或前一日低点时,我需要显示标签。我可以绘制形状,但不知道如何绘制标签。请帮助编码。
///////////////////////////////////////////////// ////////////////////////
//@version=4
study(title="CENTRAL PIVOT RANGE", shorttitle="CPR", overlay=true)
//Get Candle and Time frameDatabase
pivotType = input(title="CPR TIME FRAME", defval='D')
getSeries(e, timeFrame) =>security(syminfo.tickerid, timeFrame, e, lookahead=barmerge.lookahead_on)
//Colors
cprColor = color.blue
rColor = color.green
sColor = color.red
phColor = color.navy
plColor = color.maroon
//Line Style & Transparency
lStyle = plot.style_stepline
lTransp = 0
//Fill Transparency
fTransp = 99
//Switches
switch1 = input(title="DAILY CPR", type=input.bool, defval=true)
switch6 = input(title="PREVIOUS DAY HIGH & LOW", type=input.bool, defval=true)
//Main Pivot Data
H = getSeries(high[1], 'D')
L = getSeries(low[1], 'D')
C = getSeries(close[1], 'D')
//Central Pivot Range
P = (H + L + C) / 3
BC = (H + L) / 2
TC = P - BC + P
//Resistance Levels
R1 = P * 2 - L
R2 = P + H - L
R3 = H + 2 * (P - L)
R4 = R3 + R2 - R1
//Support Levels
S1 = P * 2 - H
S2 = P - (H - L)
S3 = L - 2 * (H - P)
S4 = S3 - (S1 - S2)
plot(switch1 ? R4 : na, title="R4", color=rColor, transp=lTransp, style=lStyle)
plot(switch1 ? R3 : na, title="R3", color=rColor, transp=lTransp, style=lStyle)
plot(switch1 ? R2 : na, title="R2", color=rColor, transp=lTransp, style=lStyle)
plot(switch1 ? R1 : na, title="R1", color=rColor, transp=lTransp, style=lStyle)
p1 = plot(switch1 ? TC : na, title="TC", color=cprColor, transp=lTransp, style=lStyle)
plot(switch1 ? P : na, title="PIVOT", color=cprColor, transp=lTransp, style=plot.style_circles)
p2 = plot(switch1 ? BC : na, title="BC", color=cprColor, transp=lTransp, style=lStyle)
plot(switch1 ? S1 : na, title="S1", color=sColor, transp=lTransp, style=lStyle)
plot(switch1 ? S2 : na, title="S2", color=sColor, transp=lTransp, style=lStyle)
plot(switch1 ? S3 : na, title="S3", color=sColor, transp=lTransp, style=lStyle)
plot(switch1 ? S4 : na, title="S4", color=sColor, transp=lTransp, style=lStyle)
//Fill Transparency in CPR
fill(p1, p2, color=color.blue, transp=fTransp)
//Previous Day High and Low
prev_day_high = security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
prev_day_low = security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
plot(switch6 ? prev_day_high : na, title="PDH", color=phColor, transp=lTransp, linewidth=1, style=lStyle)
plot(switch6 ? prev_day_low : na, title="PDL", color=plColor, transp=lTransp, linewidth=1, style=lStyle)
//Cpr Alert
cprlong=crossover(close,R1)
cprshort=crossunder(close,S1)
//Plot Cpr Alert
plotshape(cprlong, title="R1 Crossing Up", style=shape.triangleup, size=size.tiny, location=location.belowbar, color=color.green, transp=0)
plotshape(cprshort, title="S1 Crossing Down", style=shape.triangledown, size=size.tiny, location=location.abovebar, color=color.red, transp=0)