This is a simple SMA Crossover strategy that longs/shorts the SPY during strong trends, and liquidates during times of high market volatility, to withstand whipsaws (false signals). This liquidation function is especially helpful during 2011 and 2015, as it would have suffered from greater drawdowns otherwise. 

The 3 main components are as follows: 

1. When the 50 day SMA goes above the 200 day SMA, long the SPY.

2. When the 50 day SMA goes below the 200 day SMA, short the SPY. 

3. If the unrealized losses on any given day exceed $2000, liquidate. This was done by using:

if (profitloss <= -2000)

with profitloss being:

var profitloss = Portfolio[_symbol].UnrealizedProfit;

Please feel free to make any suggestions on how this can be improved. 

Author