Okay, I get it. Timing the market < time in the market, but I can't argue with the results of this strategy. Here we're going to take a look at a timing model using the popular MACD / MA Cross combination, with a dash of stop loss and a pinch of momentum indication, so let's dive in.
This is "close" to what I use for my personal indicator, although done on a different platform. A while back, I took on the challenge of learning Pine Script for my first coding experience. A lot of copy/paste was used. I published an "Advanced MACD/MA Cross" indicator, with the intent on building it into this strategy.
So yes, first of all, the main signal is a combo MACD / MA Cross on the S&P 500 index (SPX). Another important thing, likely the most important thing of all, is this strategy relies on the LOGARITHMIC movement of the S&P. This is very important. When looking at the log movement of a stock or index or whatever, you go from looking at the REAL PRICE to looking at MOMENTUM. In my years of trying to find a decent momentum indicator, I found just looking at the logarithmic movement was best.
Settings for MA Cross are fast 200 TEMA, slow 650 DEMA. I've found it best if the MA types are different (slow MA is also a slower "type") when looking at logarithmic movement. For instance, if your slow MA is an SMA, fast should be EMA. If slow MA is EMA, fast should be DEMA, so on and so forth. This will cause the slow MA to vertical shift down during bull markets and up during bear markets. The settings provided seem to give a good overall indicator of general market movements, but usually it's slow to respond to market entries. My MACD looks at exponential moving averages of 200 and 500 on the S&P, and then applies a 100 day EMA signal line. This provides good entry points in general.
When evaluating these long term trends, sometimes, unexpected things happen in the market that give potential to lose a lot of money. This strategy also implements a stop loss and market "bounce" finder. Stop loss is straight forward. If the strategy detects that the log movement of S&P has dropped by 10 points, a "bond market alert" will trigger. Conversely, the "bounce" finder looks at log movement of S&P from a rolling 17 day period, and if it's moved upwards by 10 points, a "stock market alert" will trigger.
The strategy tester is pretty good, although the equity holds a flat line through the Bond market. This is where a true portfolio backtest would come into play. Look at the list of trades from the strategy tester, input them into a spreadsheet or whatever, and see how this movement indicator would work for your favorite stock over the past several years. Chances are, it'll work pretty well, and a lot better than a buy and hold strategy. While looking, you may want to investigate leveraged long term treasury bonds (TMF) during the indicated downtime, or index LETF's during the uptrends (UPRO, TQQQ, etc.), depending on your risk tolerance.
The chart above shows the S&P compared to Vanguard's Long Term Treasury ETF (VGLT), as well as market entry and exit positions, in the first pane. Second pane is the Logarithmic movement of the S&P, and the strategies MA Cross lines. Third pane is MACD (MACD MA's not shown for clarity). Fourth pane shows the "bounce" indicator. Strategy tester goes all the way back to 1950, or the beginning of daily data for the S&P 500. You'll see a few trades missed the mark, but the profit factor is important to note (and keep in mind, this doesn't take into effect BONDS!)
P.S. disclaimer, this isn't 100% exactly what I use for my personal market entry / exit indicators. My personal bounce entry and stop-loss methodologies are slightly different, and I also track an underlying portfolio that will initiate a stop loss if neither stocks or bonds are working (i.e. 2022). And also, I'm not a financial professional, this isn't financial advice, yada yada yada.
P.P.S. please forgive me if the formatting doesn't end up right here, never published a strategy before!
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.