Attempting to Revise A Crossover Scanner...And Just Can't Figure it Out

S

SoChicago

New member
Let me start with the fact that this code below (that I am attempting to revise and simplify) actually works. I have both bullish and bearish versions. Below is a Bearish example. Its a scanner that finds stocks where at least 3 out of 4 indicators (SMA, MACD, RSI, and DMI) cross at roughly the same time near the most recent bar.

def numBars
= 2;
def minSignals = 3;
def SMAx = within(simpleMovingAvg(close, 2) crosses below simpleMovingAvg(close, 3)[-3], numbars);
def MDx = within(MACDHistogramCrossover(fastLength = 8, slowLength = 13, MACDLength = 5), numbars);
def sRSIx = within(stochRSI(13, "k period" = 21).FullK crosses below stochRSI(13, "k period" = 21).FullD, numbars);
def DMIx = within(DMI_Oscillator(5) crosses below 0, numbars);
plot scanX = smax[0] + mdx[0] + srsix[0] + dmix[0] >= minSignals;

In the revision, I only want the scanner to find tickers that have completed the SMAx crossover listed above. I no longer care about MACD, RSI, or DMI crossing too. I thought it would be easy to edit the code by working backwards. But my attempt at that doesn't work......at all. Below is what I have. I have tried so many edits and variations and none work. So I know I must be way off, would be eternally grateful if someone can help.

DOESN'T WORK
def numBars = 2;
def SMAx = within(simpleMovingAvg(close, 2) crosses below simpleMovingAvg(close, 3)[-3], numbars);
plot scanX = smax[0];
 

Similar threads

Top