Use a low lag MA, plotted on the lows, period about 10.
Higher highs and higher lows will be used to identify a stock that is trending, ie., the stock's last MA trough is higher than the previous one, AND the last MA peak is higher than the previous one.
Ensure that the distance between the troughs and peaks is at least 10 days.
Now buy any time the SP is above the MA.
Sell when the close crosses the MA(Low, 10).
You can encode this, but discretionary is better. Have your fear and greed in check for best results.