Here's a scan for hunting for either Bullish or Bearish relative performance (strength).
# Written by Nick 03/03/22
#Change the Input parameters to your liking and in the Plot section, either hash (#) or
# unhash the plot that you want to scan for, either Bull or Bear.
#Inputs
input ComparionSymbol = "SPY";
input AvgType = AverageType.SIMPLE;
input Price = FundamentalType.CLOSE;
input STMALength = 5;
input LTMALength = 21;
#Definitions
def SymbolPrc = Fundamental(Price);
def ComparisonPrc = Fundamental(Price, ComparionSymbol);
def STMA = MovingAverage(AvgType, SymbolPrc / ComparisonPrc, STMALength);
def LTMA = MovingAverage(AvgType, SymbolPrc / ComparisonPrc, LTMALength);
def MABull = STMA > LTMA;
def MABear = STMA <= LTMA;
#Plots for Scans
plot BullRP = if MABull then 1 else 0;
#plot BearRP = if MABear then 1 else 0;