% K is calculated as (current value - lowest value in the period) / (highest value in the period - lowest value in the period).
If there is no price movement in the period, the difference between the highest value and the lowest value becomes 0, resulting in "divide by zero" error.
I modified the program to use the previous value in that case.
There were several other mistakes, also I fixed them.
Hi,
In the attachment is an indicator which does similar to StochRSI. There are two input paras: RSI and K and D. When I chose RSI=14, K=2 and D=2, I get error message as follow:
...
2017.07.09 21:03:30.843 StochRSI EURUSD,H1: zero divide in 'StochRSI.mq4' (77,56)
...
But by some other timeframe there is no problem.
Why?