<pre><code>
// © munnababu
//@version=5
your text
indicator(“Pivot Points with CPR”, “Pivots”, overlay=true, max_lines_count=500, your text
max_labels_count=500)
localPivots = ta.pivot_point_levels(pivotTypeInput, localPivotTimeframeChange)
securityPivotPointsArray = ta.pivot_point_levels(pivotTypeInput, securityPivotTimeframeChange)
securityTimeframe = timeframe.isintraday ? "1D" : timeframe.period
[securityPivots, securityPivotCounter] = request.security(syminfo.tickerid, pivotTimeframe, [securityPivotPointsArray, pivotTimeframeChangeCounter(securityPivotTimeframeChange)], lookahead = barmerge.lookahead_on)
pivotPointsArray = isDailyBasedInput ? securityPivots : localPivots
//@function Sets the ending points of the currently active pivots to `endTime`.
affixOldPivots(endTime) =>
if drawnGraphics.rows() > 0
lastGraphics = drawnGraphics.row(drawnGraphics.rows() - 1)
for graphic in lastGraphics
graphic.pivotLine.set_x2(endTime)
graphic.tcLine.set_x2(endTime)
graphic.bcLine.set_x2(endTime)
if positionLabelsInput == "Right"
graphic.pivotLabel.set_x(endTime)
graphic.tcLabel.set_x(endTime)
graphic.bcLabel.set_x(endTime)
//@function Draws pivot lines and labels from `startTime` to the approximate end of the period.
drawNewPivots(startTime) =>
newGraphics = array.new<pivotGraphic>()
for [index, coord] in pivotPointsArray
levelSettings = graphicSettingsArray.get(index)
if not na(coord) and levelSettings.showLevel
lineEndTime = startTime + timeframe.in_seconds(pivotTimeframe) * 1000 * pivotYearMultiplier
pivotLine = line.new(startTime, coord, lineEndTime, coord, xloc = xloc.bar_time, color=levelSettings.levelColor, width=linewidthInput)
pivotLabel = label.new(x = positionLabelsInput == "Left" ? startTime : lineEndTime,
y = coord,
text = (showLabelsInput ? levelSettings.levelName + " " : "") + (showPricesInput ? "(" + str.tostring(coord, format.mintick) + ")" : ""),
style = positionLabelsInput == "Left" ? label.style_label_right : label.style_label_left,
textcolor = levelSettings.levelColor,
color = #00000000,
xloc=xloc.bar_time)
tcLine = line.new(startTime, coord, lineEndTime, coord, xloc = xloc.bar_time, color=levelSettings.levelColor, width=linewidthInput)
tcLabel = label.new(x = positionLabelsInput == "Left" ? startTime : lineEndTime,
y = coord,
text = (showLabelsInput ? levelSettings.levelName + " " : "") + (showPricesInput ? "(" + str.tostring(coord, format.mintick) + ")" : ""),
style = positionLabelsInput == "Left" ? label.style_label_right : label.style_label_left,
textcolor = levelSettings.levelColor,
color = #00000000,
xloc=xloc.bar_time)
bcLine = line.new(startTime, coord, lineEndTime, coord, xloc = xloc.bar_time, color=levelSettings.levelColor, width=linewidthInput)
bcLabel = label.new(x = positionLabelsInput == "Left" ? startTime : lineEndTime,
y = coord,
text = (showLabelsInput ? levelSettings.levelName + " " : "") + (showPricesInput ? "(" + str.tostring(coord, format.mintick) + ")" : ""),
style = positionLabelsInput == "Left" ? label.style_label_right : label.style_label_left,
textcolor = levelSettings.levelColor,
color = #00000000,
xloc=xloc.bar_time)
newGraphics.push(pivotGraphic.new(pivotLine, pivotLabel))
newGraphics.push(pivotGraphic.new(tcLine, tcLabel))
newGraphics.push(pivotGraphic.new(bcLine, bcLabel))
drawnGraphics.add_row(array_id = newGraphics)
if drawnGraphics.rows() > maxHistoricalPivotsInput
oldGraphics = drawnGraphics.remove_row(0)
</code></pre>
I am using below code to display Pivot and top central pivot (tc) and bottom central pivot (bc), but it is displaying only Pivot point value correctly but not the tc and bc values. I could see the Line.new is not popuyour text
lating these values correctly. Any help would be greatly appreciated.
Munna Aravinda Babu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.