Pine Script を使用すると、以下のコードで行の横にラベルを追加できます。?
下の画像とTomorrow CPRのようなラベルを事前に追加したいと思います。明日のCPRを追加したい
ラベルと今後の CPR ( 明日の CPR ) を追加する方法を教えてください。
以下にコードを追加しました
//@version=5
indicator('CPR with pivot', overlay=true, shorttitle='CPR with pivot ')
//******************LOGICS**************************
//central pivot range
pivot = (high + low + close) / 3 //Central Povit
BC = (high + low) / 2 //Below Central povit
TC = pivot - BC + pivot //Top Central povot
//3 support levels
S1 = pivot * 2 - high
S2 = pivot - (high - low)
S3 = low - 2 * (high - pivot)
S4 = low - 3 * (high - pivot)
//3 resistance levels
R1 = pivot * 2 - low
R2 = pivot + high - low
R3 = high + 2 * (pivot - low)
R4 = high + 3 * (pivot - low)
//Checkbox inputs
CPRPlot = input(title='Show Daily CPR', defval=true)
WeeklyPivotInclude = input(title='Show Weekly Pivot', defval=false)
MonthlyPivotInclude = input(title='Show Monthly Pivot', defval=false)
//******************DAYWISE CPR & PIVOTS**************************
// Getting daywise CPR
DayPivot = request.security(syminfo.tickerid, 'D', pivot[1], lookahead=barmerge.lookahead_on)
DayBC = request.security(syminfo.tickerid, 'D', BC[1], lookahead=barmerge.lookahead_on)
DayTC = request.security(syminfo.tickerid, 'D', TC[1], lookahead=barmerge.lookahead_on)
//Adding linebreaks daywse for CPR
CPColour = DayPivot != DayPivot[1] ? na : color.blue
BCColour = DayBC != DayBC[1] ? na : color.blue
TCColour = DayTC != DayTC[1] ? na : color.blue
//Plotting daywise CPR
plot(DayPivot, title = "CP" , color = CPColour, style = plot.style_linebr, linewidth =2)
plot(CPRPlot ? DayBC : na , title = "BC" , color = BCColour, style = plot.style_line, linewidth =1)
plot(CPRPlot ? DayTC : na , title = "TC" , color = TCColour, style = plot.style_line, linewidth =1)
// Getting daywise Support levels
DayS1 = request.security(syminfo.tickerid, 'D', S1[1], barmerge.gaps_off, barmerge.lookahead_on)
DayS2 = request.security(syminfo.tickerid, 'D', S2[1], barmerge.gaps_off, barmerge.lookahead_on)
DayS3 = request.security(syminfo.tickerid, 'D', S3[1], barmerge.gaps_off, barmerge.lookahead_on)
DayS4 = request.security(syminfo.tickerid, 'D', S4[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting daywise Support levels
plot(CPRPlot ? DayS1 : na, title='Daily S1', style=plot.style_circles, linewidth=1, color=color.green)
plot(CPRPlot ? DayS2 : na, title='Daily S2', style=plot.style_circles, linewidth=1, color=color.green)
plot(CPRPlot ? DayS3 : na, title='Daily S3', style=plot.style_circles, linewidth=1, color=color.green)
plot(CPRPlot ? DayS4 : na, title='Daily S4', style=plot.style_circles, linewidth=1, color=color.green)
// Getting daywise Resistance levels
DayR1 = request.security(syminfo.tickerid, 'D', R1[1], barmerge.gaps_off, barmerge.lookahead_on)
DayR2 = request.security(syminfo.tickerid, 'D', R2[1], barmerge.gaps_off, barmerge.lookahead_on)
DayR3 = request.security(syminfo.tickerid, 'D', R3[1], barmerge.gaps_off, barmerge.lookahead_on)
DayR4 = request.security(syminfo.tickerid, 'D', R4[1], barmerge.gaps_off, barmerge.lookahead_on)
//Adding linebreaks for daywise Support levels
DayR1Color = DayR1 != DayR1[1] ? na : color.red
DayR2Color = DayR2 != DayR2[1] ? na : color.red
DayR3Color = DayR3 != DayR3[1] ? na : color.red
DayR4Color = DayR4 != DayR4[1] ? na : color.red
//Plotting daywise Resistance levels
plot(CPRPlot ? DayR1 : na, title='Daily R1', style=plot.style_circles, linewidth=1, color=color.red)
plot(CPRPlot ? DayR2 : na, title='Daily R2', style=plot.style_circles, linewidth=1, color=color.red)
plot(CPRPlot ? DayR3 : na, title='Daily R3', style=plot.style_circles, linewidth=1, color=color.red)
plot(CPRPlot ? DayR4 : na, title='Daily R4', style=plot.style_circles, linewidth=1, color=color.red)
//******************WEEKLY PIVOTS**************************
// Getting Weekly Pivot .
WPivot = request.security(syminfo.tickerid, 'W', pivot[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Weekly Pivot
plot(WeeklyPivotInclude ? WPivot : na, title='Weekly Pivot', style=plot.style_circles, linewidth=1, color=color.black)
// Getting Weekly Support levels
WS1 = request.security(syminfo.tickerid, 'W', S1[1], barmerge.gaps_off, barmerge.lookahead_on)
WS2 = request.security(syminfo.tickerid, 'W', S2[1], barmerge.gaps_off, barmerge.lookahead_on)
WS3 = request.security(syminfo.tickerid, 'W', S3[1], barmerge.gaps_off, barmerge.lookahead_on)
WS4 = request.security(syminfo.tickerid, 'W', S4[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Weely Support levels
plot(WeeklyPivotInclude ? WS1 : na, title='Weekly S1', style=plot.style_cross, linewidth=1, color=color.green)
plot(WeeklyPivotInclude ? WS2 : na, title='Weekly S2', style=plot.style_cross, linewidth=1, color=color.green)
plot(WeeklyPivotInclude ? WS3 : na, title='Weekly S3', style=plot.style_cross, linewidth=1, color=color.green)
plot(WeeklyPivotInclude ? WS4 : na, title='Weekly S4', style=plot.style_cross, linewidth=1, color=color.green)
// Getting Weekly Resistance levels
WR1 = request.security(syminfo.tickerid, 'W', R1[1], barmerge.gaps_off, barmerge.lookahead_on)
WR2 = request.security(syminfo.tickerid, 'W', R2[1], barmerge.gaps_off, barmerge.lookahead_on)
WR3 = request.security(syminfo.tickerid, 'W', R3[1], barmerge.gaps_off, barmerge.lookahead_on)
WR4 = request.security(syminfo.tickerid, 'W', R4[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Weely Resistance levels
plot(WeeklyPivotInclude ? WR1 : na, title='Weekly R1', style=plot.style_cross, linewidth=1, color=color.red)
plot(WeeklyPivotInclude ? WR2 : na, title='Weekly R2', style=plot.style_cross, linewidth=1, color=color.red)
plot(WeeklyPivotInclude ? WR3 : na, title='Weekly R3', style=plot.style_cross, linewidth=1, color=color.red)
plot(WeeklyPivotInclude ? WR4 : na, title='Weekly R4', style=plot.style_cross, linewidth=1, color=color.red)
//******************MONTHLY PIVOTS**************************
// Getting Monthly Pivot
MPivot = request.security(syminfo.tickerid, 'M', pivot[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Monhly Pivot
plot(MonthlyPivotInclude ? MPivot : na, title=' Monthly Pivot', style=plot.style_circles, linewidth=1, color=color.orange)
// Getting Monthly Support levels
MS1 = request.security(syminfo.tickerid, 'M', S1[1], barmerge.gaps_off, barmerge.lookahead_on)
MS2 = request.security(syminfo.tickerid, 'M', S2[1], barmerge.gaps_off, barmerge.lookahead_on)
MS3 = request.security(syminfo.tickerid, 'M', S3[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Monhly Support levels
plot(MonthlyPivotInclude ? MS1 : na, title='Monthly S1', style=plot.style_circles, linewidth=1, color=color.red)
plot(MonthlyPivotInclude ? MS2 : na, title='Monthly S2', style=plot.style_circles, linewidth=1, color=color.red)
plot(MonthlyPivotInclude ? MS3 : na, title='Monthly S3', style=plot.style_circles, linewidth=1, color=color.red)
// Getting Monthly Resistance levels
MR1 = request.security(syminfo.tickerid, 'M', R1[1], barmerge.gaps_off, barmerge.lookahead_on)
MR2 = request.security(syminfo.tickerid, 'M', R2[1], barmerge.gaps_off, barmerge.lookahead_on)
MR3 = request.security(syminfo.tickerid, 'M', R3[1], barmerge.gaps_off, barmerge.lookahead_on)
//Plotting Monhly Resistance levels
plot(MonthlyPivotInclude ? MR1 : na, title='Monthly R1', style=plot.style_circles, linewidth=1, color=color.red)
plot(MonthlyPivotInclude ? MR2 : na, title='Monthly R2', style=plot.style_circles, linewidth=1, color=color.red)
plot(MonthlyPivotInclude ? MR3 : na, title='Monthly R3', style=plot.style_circles, linewidth=1, color=color.red)
//EMA 2
PlotEMA2 = input(title='Plot EMA 2?', defval=false)
EMALength2 = input(title='EMA Length', defval=50)
EMASource2 = input(title='EMA Source', defval=close)
EMAvg2 = ta.ema(EMASource2, EMALength2)
plot(PlotEMA2 ? EMAvg2 : na, color=color.new(color.red, 0), linewidth=1, title='EMA')