OPEN-SOURCE SCRIPT

Candle Percentage Change

//version=6
indicator("Candle Percentage Change", overlay=true)

// Calculate the percentage change
perc_change = ((close - open) / open) * 100

// Determine label color based on the percentage change
labelColor = perc_change >= 0 ? color.green : color.red

// Format the percentage change to two decimal places
labelText = str.tostring(perc_change, "#.##") + "%"

// Place the label above or below the candle
labelY = perc_change >= 0 ? high : low

// Create the label
label.new(x=bar_index, y=labelY, color=color.white, text=labelText, textcolor=color.black, size=size.normal, style=label.style_label_down)

Disclaimer