ScreenR 2.0


S&P500 Stock Market Crash Detection Strategy Tool.



Purpose and Restrictions of Usage

Detecting and avoiding stock market crashes seems to be the 'Holy Grail' of stock market strategies.
Since none of the strategies that I tested can beat the long term Buy&Hold strategy, the purpose was to detect a stock market crash on the S&P500 and step out in time to minimize losses and beat the Buy&Hold strategy.

I first developed a stand-alone A.I. tool based on an LSTM Neural Network (using TensorFlow). This approach only gave a 55% next-day prediction accurary for short/long positions. Since this result wasn't satisfactory enough, I decided a heuristic approach based on simple moving averages and volatility signals using pine-scripting provided by tradingview.com

Purpose:

  • Long-term trailing-stop strategy detecting S&P500 stock market crashes/corrections.
  • Use moving averages and volatility as a warning signal for upcoming crashes.
  • Beat the Buy&Hold strategy with around 10 trades (100% capitalize sold trade into new trade).

With the default parameters the strategy generates 5954% profit (measured between 1982 and 2018), with 6 closed trades, 100% profitable, while the Buy&Hold strategy only generates 2427% profit, so this strategy beats the Buy&Hold strategy by 2.45 times! Also this strategy detects all major S&P500 stock market crashes and corrections since 1980 depending on the Trailing Stop Smoothness parameter, and steps out in time to cut losses and steps in again after the bottom has been reached. The 5 crashes/corrections of 1987, 1990, 2001, 2008 and 2010 were successfully detected with the default parameters.

Usage

The sourcecode of the Stock Market Crash Detection Strategy is available as open-source at tradingview.com.
I also developed a more advanced spin-off pine-script generating automatic offline tradingview alert signals (via e-mail or otherwise) for upcoming S&P500 stock market crashes. If you are interested in this S&P500 Stock Market Crash Alert Generator, please drop me a message to receive the code (Price 99,- USD).

Here are some guidelines to use this Strategy:

  • 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), then keep using these parameters for future buy/sell signals on the S&P500.
  • More trades don't necessarily generate more overall profit. It is important to detect only the major crashes and avoid closing trades on the smaller corrections. Disregarding the smaller corrections generates a higher profit.
  • Watch out for the volatility alerts generated at the bottom (red). Threshold can by changed by the Volatility Warning Threshold parameter (default 200 = 2% ATR). In almost all crashes/corrections there is an alert ahead of the crash. Although the signal doesn't predict the exact timing of the crash/correction, it is a clear warning signal that bearish times are ahead!
  • The current correction in march 2018 is not yet a major crash but there was already a red volatility warning alert. If the volatility alert repeats the next weeks/months, chances are higher that a bigger crash or correction is near. As can be seen in the graphic, the deeper the crash is, the higher and wider the red volatility signal goes. So keep an eye on the red flag!
  • To use this strategy for future trades, set the end date past today and set the Sell On End Date value to false

Parameters

These are the parameters to model this strategy:

  • Fast EMA Buy: buy trigger when Fast EMA Buy crosses over the Slow SMA Buy value (use values between 10-20)
  • Slow SMA Buy: buy trigger when Fast EMA Buy crosses over the Slow SMA Buy value (use values between 30-100)
  • Minimum Buy Strength: minimum upward trend value of the Fast SMA Buy value (directional coefficient)(use values between 0-120)
  • Fast EMA Sell: sell trigger when Fast EMA Sell crosses under the Slow SMA Sell value (use values between 10-20)
  • Slow SMA Sell: sell trigger when Fast EMA Sell crosses under the Slow SMA Sell value (use values between 30-100)
  • Minimum Sell Strength: minimum downward trend value of the Fast SMA Sell value (directional coefficient)(use values between 0-120)
  • Trailing Stop %: trailing stop % distance from the smoothed close value (use values between 2-15)
  • Trailing Stop Smoothness: RMA value for smoothing out the trailing stop close value
  • Buy On Start Date: force Buy on start date even without Buy signal (default: true)
  • Sell On End Date: force Sell on end date even without Sell signal (default: true)
  • Volatility Warning Treshold: Treshold value to change volatility graph to red(default 200)

Adjust the Trailing Stop Smoothness parameter to hide/show smaller corrections/crashes:

  • 96: 6 trades, 100% profit, 5954% profit, detected crashes: 1987, 1990, 2001, 2008, 2010
  • 90: 8 trades, 100% profit, 5347% profit, detected crashes: 1984, 1987, 1990, 2001, 2008, 2010, 2011
  • 74: 9 trades, 100% profit, 4964% profit, detected crashes: 1984, 1987, 1990, 2001, 2008, 2010, 2011, 2015
  • 41: 10 trades, 100% profit, 4886% profit, detected crashes: 1984, 1987, 1990, 1998, 2001, 2008, 2010, 2011, 2015

Graphical Information

The script shows a lot of graphical information:

  • The green area shows a trading period (between buy and sell)
  • The close value is shown in light-green. When the close value is temporarily lower than the buy value, the close value is shown in light-red. This way it is possible to evaluate the virtual losses during the trade.
  • The trailing stop value is shown in dark-green. When the sell value is lower than the buy value, the last color of the trade will be red (best viewed when zoomed)
  • The EMA and SMA values for both buy and sell signals are shown as colored curves
  • The buy and sell(close) signals are labeled in blue
  • The Volatility is show below in green and red. The alert threshold (red) is default set to 200 (see Volatility Warning Threshold parameter below)

Legal Disclaimer

The ScreenR tool is supplied "as is", without any express or implied warranty including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the author be liable for any claim, damages whatsoever or other liability including direct, indirect, incidental, consequential, loss of business profits or special damages, whether in an action of contract, tort or otherwise, arising from, out of, in connection with or from the use of the ScreenR tool.
Past performances are no guarantee of future results!


Copyright © 2018 by Johan Van Barel. All Rights Reserved
www.000webhost.com