XPl0RR

Beating the S&P500 (SPX) Buy&Hold strategy by 16 times

Education
SP:SPX   S&P 500 Index
S&P500 (SPX) strategy using Stochastic RSI Min-Max, normalized Volatility and Trailing Stop signals, beats the Buy&Hold strategy by 16 times

Embarking on the quest to time the market accurately, the 'Holy Grail' of strategies, led me to create a script to approach this goal. Unlike other strategies that I tested, this one not only surpasses the long-term S&P500 Buy&Hold approach but does so by a remarkable 16.38 times!

Initially, I employed an A.I. program based on an LSTM Neural Network using TensorFlow. Despite achieving a 55% next-day prediction accuracy for short/long positions, I sought improvement using a heuristic pine-scripting approach, incorporating stochastic RSI oscillators, moving averages, and volatility signals.

With default parameters, this strategy, freely available as "XPloRR S&P500 Stock Market Crash Detection Strategy v2" delivered a staggering 2,663,001% profit since February 1871. In the same period, the Buy&Hold strategy "only" generated 162,599% profit. Picture this: a $1,000 investment in 1871 would now be worth $26,630,014 by February 2024. Check it out for yourself loading this strategy.

The script operates as a Stochastic RSI Min-Max script, automatically generating buy and sell alerts on the S&P500 SPX. What sets it apart? The strategy detects "corrections," minimizes losses using Trailing Stop and Moving Average parameters, and strategically re-enters the market after detecting bottoms using tuned Stochastic RSI signals and normalized Volatility thresholds.

Tailor its parameters to your preference, use it for strategic exits and entries, or stick to the Buy&Hold strategy and start new buy trades at regular intervals using buy signals only. In the pursuit of minimizing losses, the script has learned the effectiveness of a 9% trailing stop on trades. As you can clearly see on the upper graph (revolving around 100), the average overall green surfaces (profits) of all trades are much bigger than the average red surfaces (losses). This follows Warren Buffets first rule of trading to "Never lose money" and thus minimizing losses.

Update: Advanced S&P500 Stochastic RSI Min-Max Buy/Sell Alert Generator
I have also created an Alerter script based on the same engine as this script, which auto-generates buy and sell alert signals (via e-mail, in-app push-notifications, pop-ups etc.).
The script is currently fine-tuned for the S&P500 SPX tracker, but parameters can be fine-tuned upon request for other trackers or stocks.
If you are interested in this alerter-version script or fine-tuning other trackers, please drop me a message or mail xplorr at live dot com.

How to use this Strategy?
  • Select the SPX (S&P500) graph and set the value to "Day" values (top) and set "Auto Fit Data To Screen" (bottom-right).
  • Select in the Indicators the "XPloRR S&P500 Stock Market Crash Detection Strategy v2" script and set "Auto Fit Data To Screen" (bottom-right)
  • Look in the strategy tester overview to optimize the values "Percent Profitable" and "Net Profit" (using the strategy settings icon, you can increase/decrease the parameters).

How to interpret the graphical information?
  • In the SPX graph, you will see the Buy(Blue) and Sell(Purple) labels created by the strategy.
  • The green/red graph below shows the accumulated profit/loss in % of to the initial buy value of the trade (it revolves around 100%, 110 means 10% profit, 95 means 5% loss)
  • The small purple blocks indicate out-of-trade periods
  • The green graph below the zero line is the stochastic RSI buy signal. You can set a threshold (green horizontal line). The vertical green lines show minima below that threshold and indicate possible buy signals.
  • The blue graph above the zero line is the normalized volatility signal. You can set a threshold (blue horizontal line) affecting buy signals.
  • The red graph above the zero line is the slower stochastic RSI sell signal. You can set a threshold (red horizontal line). The red areas indicate values above that threshold.
    However real exits are triggered if close values are crossing below the trailing stop value or optionally when the fast moving average crosses under the slow one. The red areas above the threshold are rather indicative to show that the SPX is expensive and not ideal to enter. Please note that in bullish periods the red line and areas can stay at a permanent high value, so it is not ideal to use as a strict sell signal. However, when it drops below zero and the green vertical lines appear, these are strong buy signals together with a high volatility.

These Parameters can be changed
  • Buy Stochastic Lookback
  • Buy Stochastic Smoother
  • Buy Threshold
  • Buy Only After Fall
  • Minimum % Fall
  • Sell Stochastic Lookback
  • Sell Stochastic Smoother
  • Sell Threshold
  • Sell Only With Profit
  • Minimum % Profit
  • Use Sell MA
  • Fast MA Sell
  • Slow MA Sell
  • MA Sell Threshold
  • Use Buy Volatility
  • Volatility Smoother
  • Volatility Threshold
  • Use Trailing Stop
  • Use ATR (iso of a fixed percentage for the trailing stop)
  • ATR Lookback
  • Trailing Stop Factor(or fixed percentage if "use ATR" is false)
  • Trailing Stop Smoother

Important: optimizing and using these parameters is no guarantee for future winning trades!
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.