[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed: Stoch code



PureBytes Links

Trading Reference Links

Hi All,

I have a 10 period stochastic with overbought at 80 and oversold at 20
I am looking for moves that spike into OB or OS zone and don't hang around.

The idea is ....
If stochastic is below oversold then plot1 = 1
but the stochastic can only be less than Oversold for max 4 days.

After 4 days If stochastic is still below oversold then plot1 = 0 until stoch goes above oversold

Eg:
Day1 -> stoch < oversold -> plot1 = 1
Day2 -> stoch < oversold -> plot1 = 1
Day3 -> stoch < oversold -> plot1 = 1
Day4 -> stoch < oversold -> plot1 = 1

Day5 -> stoch < oversold -> plot1 = 0
Day6 -> stoch < oversold -> plot1 = 0
Day7 -> stoch < oversold -> plot1 = 0

Day8 -> stoch above oversold -> plot1 = 0

Day9 -> stoch < oversold -> plot1 = 1 (and reset the counter again as this is the first time it has been < OS )

That's what I am trying to code without success :-)
Any help would be much appreciated

Thanks
Paul