user1444534
user1444534

Reputation: 41

Tradingview Pine Script, show Close Price in plotshape text

I have a label being plotted on an ema cross. Is it possible to show the close price in the text of the label? The code below doesn't like the builtin 'close' variable I'm trying to use.

plotshape(crossover(ema1, ema2), title="Cross Over", style=shape.labelup, location=location.belowbar, color=green, size=size.normal, text=close, textcolor=white, transp=40)

Upvotes: 4

Views: 8492

Answers (1)

Tuan Tran
Tuan Tran

Reputation: 114

// mrtuanvn
//@version=4
study("Label at crossed",overlay=true)
crossed =crossover(ema(close,10), ema(close,50))
if crossed
    l = label.new(bar_index, na, tostring(close), 
         color=color.green, 
         textcolor=color.white,
         style=label.style_labeldown, yloc=yloc.abovebar)

Upvotes: 3

Related Questions