This is a backtest and algorithm for trading an asset as it either goes above or below the 5, 15, or 30 day SMA. You can pick the number of days you want to hold the asset as well. The sample data is 252 days of GSPC data but can be replaced as needed.