You should code your stochastic comparing statement like this instead:
1
2
3
sto=Stochastic[3,5](Close)
condition=sto[2]<sto
The “sto” variable array will be built on the fly by the platform, so you just have to refer to this array of data with number under bracket considering the last n value.
Thanks for the suggestion, it works much better. Although I still get slightly different results compared to the”original”, but I’ll keep working on it. 🙂