Colored Pivot With Colored Ema Mobile
Colored Pivot With Colored Ema Mobile
0
at https://mozilla.org/MPL/2.0/
// © KULDEEP157
//@version=6
indicator("COLORED PIVOT WITH EMA", "COLORED PIVOT WITH EMA", overlay=true,
max_lines_count=500, max_labels_count=500)
// Calculate EMA
ema_value = ta.ema(close, ema_length)
// EMA color
ema_color = ema_value > ema_value[1] ? color.new(#00FF08, 0) : color.new(#FF0000,
0)
// Plot EMA
plot(ema_value, color=ema_color, title="EMA", linewidth=2)
type pivotGraphic
line pivotLine
label pivotLabel
pivotTimeframeChangeCounter(condition) =>
var count = 0
if condition and bar_index > 0
count += 1
count
affixOldPivots(endTime) =>
if drawnGraphics.rows() > 0
lastGraphics = drawnGraphics.row(drawnGraphics.rows() - 1)
for graphic in lastGraphics
graphic.pivotLine.set_x2(endTime)
if positionLabelsInput == "Right"
graphic.pivotLabel.set_x(endTime)
drawNewPivots(startTime) =>
newGraphics = array.new<pivotGraphic>()
for [index, coord] in pivotPointsArray
if index < array.size(graphicSettingsArray)
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 = color.new(#000000, 100),
xloc=xloc.bar_time)
newGraphics.push(pivotGraphic.new(pivotLine, pivotLabel))
drawnGraphics.add_row(array_id = newGraphics)
if drawnGraphics.rows() > maxHistoricalPivotsInput
oldGraphics = drawnGraphics.remove_row(0)
for graphic in oldGraphics
graphic.delete()
if (securityPivotDrawConditionStatic or localPivotDrawConditionStatic)
affixOldPivots(time)
drawNewPivots(time)