P = 10 //periods over which to scan for multiple crossovers
N = 2 //number of crossovers occurred with the last P bars to
// tell the two EMAs were intertwining
Ema10 = average[10,1](close)
Ema50 = average[50,1](close)
BullishCROSS = Ema10 CROSSES OVER Ema50
BearishCROSS = Ema10 CROSSES UNDER Ema50
Crossovers = BullishCROSS OR BearishCROSS
// check if there were too many crossovers within P periods
c1a = (summation[P](Crossovers) < N)
c1b = (summation[P](Crossovers) >= N)
c1 = c1a AND c1b[1]
// check if the distance between the two EMAs is > than its average
EmaGap = abs(Ema10 - Ema50)
GapAverage = average[P](EmaGap)
c2 = EmaGap > GapAverage
// check that the GAP betweemn the two EMAs is increasing, using a
// 1-bar comparison, or a comparison over multiple periods using
// SUMMATION
c3 = EmaGap > EmaGap[1]// or (summation[2](EmaGap > EmaGap[1]) = 2)
Cond = c1 AND c2 AND c3
Screener[Cond AND (high <> low)]