I'm learning C# and NinjaScript and am working with an indicator to help with this.
I have an alert indicator that gives me an audio alert, paints the candlestick bars a different color and draws a horizontal line when the RSI is above 50 or below 45.
But the horizontal lines drawn would stay on the chart the entire time I was analyzing the markets, which is not what I want.
I only want for the horizontal line that corresponds to the current condition of the RSI (bullish or bearish) to be there.
So I created a While Loop hoping to have one of the horizontal lines that were drawn, the one that no longer applies, to be removed from the chart when the RSI changes from bullish to bearish or vise versa.
But that seems to have created an infinite loop. My computer was getting stuck. But I was able to later comment out that While Loop code.
Screenshot attached.
Any other such loops or code that I can use to have only one of the horizontal lines present, based on if the RSI is above 50 or below 45?
How about a Switch Statement or If Else Statement? Any suggestions?
Comment