Here’s the code:
# MA Reversal
input price = close;
input length = 20;
input displace = 0;
def SMA = Average(price[-displace], length);
def LE;
if ((low < SMA) and ( close[1] > SMA ) and (close > open)) {
LE = 1;
} else {
LE = 0;
}
plot long = LE;
long.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
long.SetDefaultColor(color.GREEN);
All this looks for are instances in which a stock has touched a moving average and finished green on the day.
Now we can apply this screener to a list of stocks.
Here are the conditions to use on the thinkorswim scanner: