ALEModerator
Master
Hello Guys, Nicolas
I’m asking to code the following opposite stochastic divergences that could be a long entry signal.
Thanks in advance
Ale
Please add a complete example from any instrument with date/hours and stochastic parameters.
Divergences are sometimes easily spotted with eyes but a quite difficult to get them with code.
ALEModerator
Master
Hello Nicolas,
yes is very difficult..
I’ve attached another picture hoping to be more clear
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.
sto = stochastic[p,k]
avg = average[d](sto)
lookback = 20
//bullish divergence
//first sto cross
if sto crosses over avg then
currentsto = sto//[1]
currentprice = lowest[3](low)
endif
//previous sto cross
if barindex<>mybar then
for i = 1 to lookback do
if sto[i] crosses over avg[i] then
previoussto = sto[i]
previousprice = lowest[i+3](low)
mybar = barindex[i]
break
endif
next
endif
//divergence or not?
if currentsto<previoussto and currentprice>previousprice then
bulldiv = 1
else
bulldiv = 0
endif
return bulldiv
ALEModerator
Master
Hello Nicolas,
fantastic, its perfect. I need to observe noises to proceed to add filter and other solutions to avoid false positive signals.
We are studing a scalper strategy based on Stochastic divergences and opposite divergences. We Keep you informed on our progress
Thanks
Ale