1

I need to plot labelup and labeldown signals whenever rsi with lenght 21 crosses an SMA with lenght 5. Originally, they are Oscillators with overlay set as false. All I just need is the correct syntax for the crossover and the Buy/Sell Labels visible above and below the price bars without the SMA and RSI lines visible on chart?

Below is the lines of code to calculate and plot. The compiler's error message says 'Undeclared identifier' "cross".

// plot the up label

rsi_cross_up = cross and sma > rsi
plotshape(rsi_cross_up, shape.labelup, location=location.belowbar, color=color.new(color.green,0), size=size.tiny)

// Plot down label whenever sma crosses rsi upwards

rsi_cross_up = cross and rsi > sma
plotshape(rsi_cross_dn, style=shape.labeldn, location=location.abovebar, color=color.new(color.red,0), size=size.tiny)

Please note that the version is pinescript version 5.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57

1 Answers1

0

The plotshape style syntax is shape.labeldown not shape.labeldn

Something like that

// plot the up label
rsi_cross_up = cross and sma > rsi
plotshape(rsi_cross_up, shape.labelup, location=location.belowbar, color=color.new(color.green,0), size=size.tiny)

// Plot down label whenever sma crosses rsi upwards
rsi_cross_up = cross and rsi > sma
plotshape(rsi_cross_dn, style=shape.labeldown, location=location.abovebar, color=color.new(color.red,0), size=size.tiny)
Gu5tavo71
  • 706
  • 1
  • 4
  • 11