First time close under a moving average in x number of bars


New member
Im trying to setup a scan looking for trends that are on the verge of dying. so im looking for strong stocks that have respected a certain moving average, we'll say the 10 week.

1) its consecutively closed over the 10 week ma for 10 weeks, but week 11 now has closed below it. Do I need to specify a lookback period of 11 in this case and do I need to compare close to each of the 11 periods moving averages and count the streak using compound value? sorry if its confusing Ive been messing with this one for a bit.


Well-known member
@EDDY GARCIA Here is a scan that consecutively closed above the 10 week moving average but for the 11th week closed below it.
Make sure you run this on a WEEKLY aggregation on the scanner.
I just scanned the S&P 500 and obtained 3 hits - HCP, HD and SO

# Dying Trends Scan
# tomsk
# 11.11.2019

def MA = Average(close, 10);
plot scan = sum(close[1] > MA[1], 10) == 10 and close < MA;
Last edited:

Similar threads