Algorithm uses Relative Strength Index (RSI) to control entry into market, and then martingale to double down on losses when the trade goes wrong.

It attempts to break even but once the leverage is maxed out it declares failure and liquidates.

I wanted to demonstrate the characteristic dramatic crash that eventually happens with martingale strategies which happened here in Nov-2007 and Oct-2011.

RSI and SetHoldings classes taken from the Community Code Library.