Note: This is a modified version of TradingView's built-in "Divergence Indicator" and applied in "Strategy" format to show back testing results It finds bullish and bearish divergence in a selection of well known MA formulas: MACD, RSI, STOCH, DETRENDED PRICE OSCILLATOR, MOMENTUM.
I've found good results even on 1 minute charts!
In this example the chart backtest is utilizing the detrended price oscillator (DPO)
There are multiple variables, so the ability to find good back test can sometimes be "time consuming" And please note that if you increase "Pivot LookBack Right" variable too high, then you will increase chance of repaint. Keep this variable as low as possible
I've also drawn my own solutions on the chart (red and green trend lines) to find good take profit and safe stop loss. In order to study this properly you need the own the chart. Scripts don't give you this option. See private chart publication link to "own" the chart for yourself. Simply click on the "Share" button (it's the megaphone icon) and click on "Make it Mine"
I've found the best approach is to create 5 copies of indicator on 1 chart and have each running with different MA formula. This will give you a majority consensus type environment.