200 SMA

Is there a formula that would allow me to only invest in a stock that has its 200-day SMA moving/trending upwards. Is this possible?

You could try something like;

sma(200,0)>sma(200,20)

That requires that the current SMA200 be great than it was 20 days ago.

Walter