Well .. I think it should work for the bullish divergences you are trying to catch.
But there are of course too many of them with short term period of your stochastic parameters (5,3,3). You should also try to add overbought/oversold level to catch better cases of the stochastic reversal and to avoid whipsaws that the indicator made with its moving average.
In this code, I use the cross of the stochastic with its moving average to spot reversal and then compare the last 2 different levels with the 2 last prices.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue