Search code examples
pine-scriptpine-script-v5pine-script-v4

Print the pourcentage of each candle


Is it possible to print on the top or buttom of each candle the value like the % ? Like this one (just the %)

enter image description here


Solution

  • Calculate the price change in percentage then use the label.new() function to create your labels.

    //@version=5
    indicator("My script", overlay=true, max_labels_count=500)
    
    per = ((close-close[1]) / close[1]) * 100
    per_s = str.format("{0,number,#.##}", per)
    
    label.new(bar_index, high, per_s)
    

    enter image description here