This script uses the RSI and RSI divergences to mark signals where the rsi is both below/above the 50, below/above its moving average, and where the last regular or hidden divergence matches that state. The RSI is built into the indicator, so you don't need it in your bottom pane if you don't want it, I just put one there for illustrative purposes. Please note it will not print the same signal consecutively, as it is meant to show an overall direction, not the in and out fluctuations. I suggest using it in conjunction with some moving averages so you can ignore signals not in the trend.