Quantcast
Channel: System Trader Success
Viewing all articles
Browse latest Browse all 323

Market Seasonality Study

$
0
0

In a previous article, “First Of The Month Market Edge“, we took a look at an intraday strategy that involved entering a long position on the S&P at the opening of trading on the first day of the month and closing that trade at the end of the trading day. We called this the “first of the first-of-the-month” strategy and showed the months of January, February, March and April produced very strong positive results and the months of June and December produced very weak results. In this article I would like to explore another calendar based market edge. This edge is the familiar seasonality of buying the S&P in the fall and selling in the spring.

Seasonality Bias

First, I would like to test the popular trading idea of buying the S&P in October and selling in May. I will test this on the cash market going back to 1983. The number of shares to buy will be adjusted based upon a fixed amount of risk. In this case, $5,000 is risked per trade based upon the volatility of the market. As this is a simple market study no slippage or commissions were taken into account. The EasyLanguage code looks like this:

CurrentMonth = Month( Date );
 
If ( CurrentMonth = BuyMonth ) And ( MP = 0 ) Then
Buy(“Buy Month”) iShares contracts next bar at market;
 
If ( CurrentMonth = SellMonth ) Then
Sell(“Sell Month”) iShares contracts next bar at market;

Testing Environment

I decided to test the strategy on the S&P cash index going back to 1960. The following assumptions were made:

  • Starting account size of  $100,000.
  • Dates tested are from 1960 through July 2013.
  • The number of shares traded will be based on volatility estimation and risking no more than $5,000 per trade.
  • Volatility is estimated with a three times 20-week 40 ATR calculation. This is done to normalize the amount of risk per trade.
  • The P&L is not accumulated to the starting equity.
  • There are no deductions for commissions and slippage.
  • No stops were used.

From here we can plug into the input values the buy month (November) and sell month (May). Doing this we generate the following equity graph:

Seasonality_Study_EQ_Graph

SeasonalityPerformance

It sure looks like these months have a long bias as those are some nice results. What would the equity curve look like if we reverse the BuyMonth and SellMonth? That is, let’s buy in May and sell in November. Below is the equity curve for this inverted system.

Inverted_Seasonality_Study_EQ_Graph

From 1983 to 1987 this period was producing positive results. That equity peak is 1987 and that year should be familiar. That was the year we had the massive one day market crash on October 19th known as Black Monday. The Dow Jones Industrial Average dropped 22% in one day. Since that event the behavior of market participants has been altered. This is not unlike the radical market changes which occurred after the 2000 market peek where much of the trending characteristics of the major markets were replaced by mean reversion tendencies.

So far the basic seasonality study looks interesting. However, keep in mind we do not have any stops in place. Nor do we have any entry filter that would prevent us from opening a trade during a bear market. If the market is falling strongly when our BuyMonth rolls around we may not wish to purchase right away. Likewise, we have no exit filter to prevent us from exiting when the market may be on a strong rise during the month of May. It’s conceivable that the market may be experiencing a strong bull run when our usual SellMonth of May rolls around.

Short-Term Trend Filter

In order to avoid buying and selling at the wrong times I’m going to introduce a 40-period simple moving average (SMA) to act as a short-term trend filter. I picked 40 days because this represents about two months worth of trading. This filter will be used to prevent us from immediately buying into a falling market or selling into a rising market. For example, if our SellMonth of May rolls around and the market happens to be rising (trading above the 40-period SMA), we do not sell just yet. We wait until unit price closes below the short-term SMA. The same idea is applied to the buying side, but reversed. We will not go long until price closed above the short-term SMA.

Within EasyLanguage we can create a buy/sell confirmation flag called BuyFlag and SellFlag which will indicate when the proper go-long or sell conditions appear based upon our short-term trend filter.

if ( MinorTrendLen > 0 ) Then BuyFlag = Close > Average( Close,  MinorTrendLen )
Else BuyFlag = true;

If ( MinorTrendLen > 0 ) Then SellFlag = Close < Average( Close, MinorTrendLen )
Else SellFlag = true;

The MinorTrendLen variable is actually an input value which holds the look-back period to be used in the SMA calculation. You will notice there is an additional check to see if the look-back period is zero. This is done so we can enable or disable this short-term filter. If you enter zero for the look-back period, the code will always set our BuyFlag and SellFlag to true. This effectively disables our short-term market filter. This is a handy way to enable and disable filters from the system inputs.

Below is performance of both our Baseline system and the system with our short-term filter:

PerformanceShortTermFilter

We increased the net profit, average profit per trade, annual rate of return and the expectancy score. The profit factor went down a bit as our max intraday drawdown increased slightly. Overall it looks like the short-term filter adds value.

MACD Filter

A standard MACD filter is a well known indicator that may help with timing. I’m going to add a MACD calculation, using the default settings, and only open a new trade when the MACD line is above zero. Likewise, I’m only going to sell when the MACD line is below zero.  Within EasyLanguage we can create a MACD filter  by creating two Boolean flags called MACDBull and MACDBear which will indicate when the proper major market trend is in our favor.

If ( MACD_Filter ) Then
Begin
 MyMACD = MACD( Close, FastLength, SlowLength );
 MACDAvg = XAverage( MyMACD, MACDLength );
 MACDDiff = MyMACD - MACDAvg;

 If ( MyMACD crosses over 0 ) Then
 Begin
    MACDBull = True;
    MACDBear = False;
 End
 Else If ( MyMACD crosses under 0 ) Then 
 Begin
    MACDBull = False;
    MACDBear = True;
 End;
End
Else Begin
    MACDBull = True;
    MACDBear = True;
End;

Below are the results with the MACD filter:

PerformanceMACDFilter

Utilizing the MACD filter and comparing it to our baseline system, we  improved some of the performance metrics such as net profit, average net profit per trade and annual rate of return. However, some other values did not do as well. Furthermore, it does not appear to be better than our short-term filter.

RSI Filter

For our final filter I will try the RSI indicator with its default loopback period of 14. Again, like the MACD calculation, I want price moving in our direction so I want the RSI calculation to be above zero when opening a position and below zero when closing a position.

If ( RSI_Filter ) Then
Begin
   RSIBull = RSI(Close, 14 ) > 50;
   RSIBear = RSI(Close, 14 ) < 50;
End
Else Begin
   RSIBull = true;
   RSIBear = true;
End;

SeasonalityRSIFilter

Conclusion

The RSI filter performed better than the MACD and maybe even better than the short-term SMA filter depending upon what metrics you find important. We do see the RSI filter produces the highest profit factor, percent winners and sharpe ratio. Yet, the net profit is lower than the short-term SMA filter and the Expectancy Score is the worst of them all. In the end it does appear applying a SMA filter or an RSI filter can improve the baseline results. Both filters are rather simple to implement and were tested for this article with their default values. You of course could take this much further.

It certainly appears there is a significant seasonal edge to the S&P market. The very trading rules we used above for the S&P cash market could be applied to the SPY and DIA ETF markets. I’ve tested those ETFs and they produce very similar results. The S&P futures market also produces similar results. It even appears to work well on some stocks. Keep in mind this market study did not utilize any market stops. How can this study be used? With a little work an automated trading system could be built from this study. Another use would be to apply this study as a filter for trading other systems.

This seasonality filter could be applied to both automated trading systems or even discretionary trading. It may not be much help for intraday trading, but it may. Further testing would be needed. Anyway, just being aware of these major market cycles can be helpful in understanding what’s going on with today’s markets and where they may be going in the near future. Hope you found this study helpful.

Downloads

Seasonal Strategy (TradeStation ELD)
Seasonality Strategy WorkSpace (TradeStation TWS)
Seasonal Strategy (Text File)


Viewing all articles
Browse latest Browse all 323

Trending Articles