RSI Indicator with Martingale Position Sizing
Martingale is a bet sizing technique for increasing odds of winning at the expense of increased risk. The classic example is a coin flipping game where the gambler doubles his bet if he loses, in the hopes of making back any losses to break even. He will continue doubling his bet through subsequent losses until the bet breaks even. Once he returns to whole he continues betting with a unit bet. In theory with infinite capital and exactly 50-50 probability martingale can ensure the gambler will always return a profit.
Martingale position sizing is sometimes used in trading strategies without knowing its true risks. When implemented in reality traders have limited leverage, and the market win-loss probability fluctuates as losses can when the market is range-bound. It is a certainty that with a sufficient sample size eventually catastrophic loss does occur, it’s just a matter of when.
To demonstrate this we built a martingale position management algorithm, and backtest it on 15 years of data in QuantConnect to highlight the crashes.
To decide entry points we chose a the popular Relative Strength Index (RSI) indicator and shorted when it was over 70, signalling it was overbought. Conversely we entered the market long when it was less than 30, signalling oversold. Our entry and exit conditions were fairly arbitrary because we wanted to explore martingale position sizing more than RSI.
Once the algorithm was vested we monitor for a minimum profit gain, and on achieving the minimum profit-gain we exit the strategy locking in the profit.
In the event the algorithm reaches our maximum loss, we record the trade loss and double-invert the position as per martingale rules. The trade’s loss is now attached to a “loss-chain” parameter which serves as memory of this doubling-sequence. The minimum profit gain must also recoup the loss-chain before resetting to start again.
Our backtest result shows our implementation beating the absolute return of the SPY over a 15 year period, but it has greater volatility resulting in a lower Sharpe Ratio (0.4 vs 1.1 S&P). Interestingly it demonstrates the characteristic crashes of a martingale strategy, but since we have fixed leverage the crashes never rebound to form the perfect straight line.
There are many areas for experimentation to improve the strategy performance, such as using more intelligent entry and exit techniques, anti-martingale position sizing and adjusting our entry and loss targets based on market volatility. But I’ll leave that for you to explore!