input length = 14;

input price = close;
def
def
def
def

NetChgAvg = WildersAverage(price - price[1], length);
TotChgAvg = WildersAverage(AbsValue(price - price[1]), length);
ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
RSI = 50 * (ChgRatio + 1);

plot scanit = sum(((sum(close>close[4],9)==9 && sum(close>close[4],9)[1]==8)OR(s
um(close<close[4],9)==9 && sum(close<close[4],9)[1]==8)) and
((Sum(RSI < RSI[4], 9) == 9 && Sum(RSI < RSI[4], 9)[1] == 8) or (Sum(RSI > RSI[4
], 9) == 9 && Sum(RSI > RSI[4], 9)[1] == 8)),59) >= 3 ;