0

I have an indicator that I copied and modified. It plots a green line when the "IF_RSI" variable is greater than 0.8.

However, when I scan through the bars, sometimes the value of the indicator shows +1, sometimes -1 and sometimes Ø. Only the -1 changes the color of the plot to red, the other 2 values paint it green.

My problem is that I want to use this indicator with others to generate a buy signal when it's green and a sell signal when it's red. For that I use: IF_RSI > 0.8. However, when the value of this variable is Ø, it gives me a sell signal even though on the line on the plot is still green. My question is what does Ø mean? and how can I test for it? Simply testing IF_RSI == Ø gives an error message.

Best example of where it changes to Ø is on the 3 min tesla chart on Oct 31, 2022 at 11:06 am. Any help would be greatly appreciated ``

//@version=5

indicator(title='V7-I-F-MC-InvFisherWMA-13-09-22 ', shorttitle='V7_IF_WMA_VI_RSI')
// based on: Inverse Fisher WMA RSI and ROC of Vortex by drnkk copy
//Inputs
RSI_pm = input(5, title="RSI Main Period")
RSI_ps = input(1, title="RSI Smooth Period")

//RSI Calculation
raw_RSI = 0.1 * (ta.rsi(close, RSI_pm) - 50)
wma_RSI = ta.wma(raw_RSI, RSI_ps) * 100

IF_RSI = (math.exp(2 * wma_RSI) - 1) / (math.exp(2 * wma_RSI) + 1)

iff_1 = IF_RSI < -0.8 ? color.red : color.gray
plot(IF_RSI, color=IF_RSI > 0.8 ? color.lime : iff_1, linewidth=3)

hline(0)

``

Adam B
  • 93
  • 1
  • 3
  • 13

1 Answers1

1

By default the plot style is plot.style_line and it is continuous. This means, even if the value is na it will draw a line from the last valid number to the next valid number.

If you don't want to see a line when the value is na, you can change your plot's type to plot.style_linebr or plot.style_circles.

enter image description here

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • Thank you, that makes a lot of sense. I was wondering why the line keeps drawing even with the Ø. I guess that means that Ø is na. How can I test for na. for ex. I have a sell signal if this indicator is != 1. but what if it is na. ... ==na ? – Adam B Nov 02 '22 at 19:59
  • There is `na()` function for that. `na(x)`: Returns `true` if `x` is `na`, `false` otherwise. – vitruvius Nov 02 '22 at 20:23