Algorithmic Trading Tips 11.



Every year, the old adage “Sell in May and go away” is widely discussed in the financial media. But is this adage reality or just a myth? And can this simple seasonal strategy work at all if everyone knows it? Using Tradesignal; traders, portfolio managers and analysts can examine these and other seasonal pricing anomalies quickly and safely to improve their investment decisions.

WATCH VIDEO NOW. (4 minutes to improve your performance.)

By downloading you agree to the terms of use below.

Empirical evidence for summer weakness.

In 1964 the Financial Times wrote about the “Sell in May” effect, it took decades for the academic world to study this phenomenon, which says shares should be avoided during the summer months. The most comprehensive study on this subject was published in 2002 (The study can be downloaded here.). The research duo Sven Bouman and Ben Jacobsen examined a total of 37 international stock market indices of different industrialised and emerging countries and calculated the respective performance and risk figures for the period from November to April (winter period) and the period from May to October (summer period) in order to compare them.

The results were clear: 36 of the 37 examined stock markets revealed a significant “Sell in May” effect, that is the performance of a buy-and-hold investor was worse than that of the investor, who did not hold any shares in the months of May through October and re-boarding in November to stay invested until the end of April. Also, from a risk perspective, the winter period turned out to be a better choice over the summer period: The standard deviation was lower for the “sell in May” strategy compared to the passive buy-and-hold approach.

Seasonal indicator in the practical test.

To ensure the extent to which the seasonal pattern still works today, every trader should create their own analysis. One possibility here is the application of an indicator, which enables you to visualize such a seasonal pattern in no time at all. Figure 1 shows the seasonal pattern of the Dow Jones Industrial Average on the basis of the last 10, 20, 30 and 40 years. The result confirms the formation of a major high between late April and mid-May and the subsequent sideways or downward movement of the stock markets in the summer months. At the same time the formation of a seasonal low typically can be observed at the beginning of October. However, interestingly, is the fact that this pattern has not undergone any great variations with time.


The old adage “Sell in May and go away” is reflected in reality. In the last decades, the Dow Jones performed significantly weaker between May and September than between October and April.


Trading strategy code in Equilla.

Whether you want to use this information as a filter for other trading signals or for adjustment of the position size to the seasonal trend – using Tradesignal the implementation of the “Sell in May” strategy into a program code and the subsequent evaluation is a simple task. For this purpose, just copy and paste the following code as a new trading strategy and store it for later use. The process is explained in detail in our Trading Tips video.

The following program lines contain the instructions for the long entry at the beginning of October and getting out again in early May. Of course, further components such as a trend filter or an initial stop can be implemented – for our present purpose it was intentionally waived.


Synopsis(​​ "Use this dashboard in a Watch List or in a Market Scanner. It displays conditions of 4 indicators (RSI, MACD, Slow Stochastics, Bollinger Bands) simultaneously. If the​​ indicator is in a buy condition, the cell is colored green. If it is in a sell condition the cell is colored red. The conditions are as shown below under the 'conditions' section."​​ ),

SubChart(​​ False​​ ),

ShortCode(​​ "SBDB"​​ );

 ​​ ​​ ​​ ​​ ​​​​ 



 ​​ ​​ ​​​​ greenColor(​​ ColorDarkGreen​​ ),redColor(​​ DarkRed​​ ),​​ FlatColor(​​ transparent​​ ),lookback(1),realtime(true),

Period(​​ NumericSimple​​ );















if​​ realtime​​ then​​ displace=0​​ else​​ displace=1;



rsiValue​​ =​​ RSIClassic(​​ close,​​ P_RSI );

color​​ =​​ Iff( rsiValue[displace]​​ >​​ 70,​​ redColor,​​ Iff( rsiValue[displace]​​ <​​ 30,​​ greenColor,​​ FlatColor ) );

summe​​ =​​ Iff( rsiValue[displace]​​ >​​ 70,​​ summe-1,​​ Iff( rsiValue[displace]​​ <​​ 30,​​ summe+1,​​ summe ) );

if​​ Draw_all​​ then Draw( rsiValue[displace],​​ "RSIC",​​ Default,​​ Default,​​ Default,​​ color );


result​​ =​​ MACD(​​ Close,​​ P_MACD_Fast,​​ P_MACD_Slow );

triggerValue​​ =​​ XAverage( result,​​ P_MACD_trigger );

color​​ =​​ Iff(( result[displace]​​ >​​ 0​​ ),​​ greenColor,​​ Iff( result[displace]​​ <​​ 0​​ ,​​ redColor,​​ FlatColor ) );

summe​​ =​​ Iff((result[displace]​​ >​​ 0​​ ),​​ summe+1,​​ Iff(result[displace]​​ <​​ 0​​ ,​​ summe-1,​​ summe​​ ) );

if​​ Draw_all​​ then Draw( result[displace],​​ "MACD",​​ Default,​​ Default,​​ Default,​​ color );


bblower​​ =​​ BollingerBand(​​ close,​​ P_BB, -2​​ );

bbupper​​ =​​ BollingerBand(​​ close,​​ P_BB,​​ 2​​ );

color​​ =​​ Iff(​​ close​​ <​​ bblower[displace],​​ greenColor,​​ Iff(​​ close​​ >​​ bbupper[displace],​​ redColor,​​ FlatColor ) );

summe​​ =​​ Iff(​​ close​​ <​​ bblower[displace],​​ summe+1,​​ Iff(​​ close​​ >​​ bbupper[displace],​​ summe-1,​​ summe ) );

if​​ Draw_all​​ then Draw( bblower[displace],​​ "BB_low",​​ Default,​​ Default,​​ Default,​​ color );

if​​ Draw_all​​ then Draw(​​ bbupper[displace],​​ "BB_upper",​​ Default,​​ Default,​​ Default,​​ color );



slow_k​​ =​​ SlowK( P_SS );

color​​ =​​ Iff( slow_k[displace]​​ <​​ 20,​​ greenColor,​​ Iff( slow_k[displace]​​ >​​ 80,​​ redColor,​​ FlatColor ) );

summe​​ =​​ Iff( slow_k[displace]​​ <​​ 20,​​ summe+1,​​ Iff(​​ slow_k[displace]​​ >​​ 80,​​ summe-1,​​ summe ) );

if​​ Draw_all​​ then Draw( slow_k[displace],​​ "Stoch K",​​ Default,​​ Default,​​ Default,​​ color );



if​​ summe​​ >3​​ then​​ farbe=ColorForestgreen;

if​​ summe​​ >2​​ and​​ summe​​ <=3​​ then​​ farbe=green;

if​​ summe​​ >0​​ and​​ summe​​ <=2​​ then​​ farbe=ColorGreen;

if​​ summe​​ =0​​ then​​ farbe=white;

if​​ summe​​ <0​​ and​​ summe​​ >=-2​​ then​​ farbe=ColorFireBrick;

if​​ summe​​ <-2​​ then​​ farbe=ColorMaroon;​​ 


​​ if​​ Draw_all​​ then Draw( summe,​​ "Sum",​​ Default,​​ Default,​​ Default,​​ farbe );




if​​ diff​​ >3​​ then​​ farbe=ColorForestgreen;

if​​ diff​​ >2​​ and​​ diff​​ <=3​​ then​​ farbe=green;

if​​ diff​​ >0​​ and​​ diff​​ <=2​​ then​​ farbe=ColorGreen;

if​​ diff​​ =0​​ then​​ farbe=white;

if​​ diff​​ <0​​ and​​ diff​​ >=-2​​ then​​ farbe=ColorFireBrick;

if​​ diff​​ <-2​​ then​​ farbe=ColorMaroon;​​ 


if​​ Draw_all​​ then Draw(​​ diff,​​ "Difference",​​ Default,​​ Default,​​ Default,​​ farbe );



This simple code contains the instruction for long entry in early May while the exit takes place in early October.


Let’s take a look at how the equity curve of this primitive seasonal approach would have developed in the past for the DAX. Figure 2 shows impressively that staying away from the stock market during the summer months on balance represented a good decision. On the basis of the equity curve you can see that this simple trading rule has outperformed a passive buy- and-hold investment in the DAX over the last 20 years both in terms of performance and on the basis of volatility.


The simple “Sell in May” strategy has beaten a passive buy-and-hold approach for the DAX in the last 20 years.

This statement is also true for other benchmarks like the S&P 500. Especially in bear market phases the long exit by the end of April turned out to be an excellent timing signal, since the majority of the drawdowns could be avoided by following the “Sell in May” approach – the summer months of 1990, 2001, 2002 and 2008 serve as good examples here.

Admittedly one thing may not be concealed at this point: No seasonal pattern is set in concrete! While skipping the summer months has been of beneficial in strong downward phases, in certain bull market years, the flip side of the coin is evident: An investor who followed the “Sell in May” strategy in the years 1993, 1997 or 2005 and 2012 missed significant gains.

What does the performance report say?

Finally let us analyze the results. By clicking on the performance button Tradesignal provides a detailed insight into dozens of key figures such as:

  • Net profit / loss
  • Hit rate
  • Profit Factor
  • Maximum Drawdown


For the DAX, the “Sell in May” approach can be summarized as follows: Since 1991, 22 trades were carried out – 19 of which ended with a positive result. Excluding transaction costs, a net gain of around 12000 points total was generated, the largest drawdown was around 3100 points. Figure 3 shows an excerpt of the performance report – this time for the Dow Jones Industrial Average since 1950.


The “Sell in May” strategy has achieved a hit rate of almost 75 percent since 1950.

With a hit rate of 75 per cent, the seasonal strategy was successful. The report also includes another important message: The “Sell in May” strategy generated four false signals in a row in the late seventies – proof that the seasonal approach by no means has to work every year.



The reasons for the “Sell in May” or Halloween effect still aren`t exactly clear, but one cannot be dismissed out of hand: In the past, the famous adage of selling at the beginning of May and reentering the stock market in October very often proved to be the right decision. However, it must be noted that the assessment of these seasonal strategy greatly depends both on the chosen market and the investment period. Basically, this price anomaly is a kind of loss limiting approach, which also has its price if the market rises over the summer. With Tradesignal almost all price patterns and trading approaches can be translated in clear, rule-based strategies and tested so that wrong decisions can be eliminated. By the way, if you need any help, just contact our support team and we would be pleased to contribute to your success.

That`s it for today. Take care, take profit.
David Pieper


© Copyright Tradesignal Ltd., London.
Distribution allowed under a Creative Commons Attribution-Noncommercial license

Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is specifically prohibited. All other protected brands and trademarks mentioned in this document conform, without restriction, to the provisions of applicable trademark law and the copyrights of the respective registered owners.

Tradesignal Ltd. obtains information from sources it considers reliable, but does not guarantee the accuracy or completeness of its information contained therein. Tradesignal Ltd. and its affiliates make no representation or warranty, either express or implied, with respect to the information or analysis supplied herein, including without limitation the implied warranties of fitness for a particular purpose and merchantability, and each specifically disclaims any such warranty. In no event shall Tradesignal Ltd. or its affiliates be liable to for any decision made or action taken in reliance upon the information contained herein, lost profits or any indirect, consequential, special or incidental damages, whether in contract, tort or otherwise, even if advised of the possibility of such damages. This material does not constitute an offer or a solicitation of an offer or a recommendation to buy or sell securities. All expressions of opinion are subject to change without notice.

This code is provided free of charge and “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of fitness for a particular purpose and noninfringement. In no event, shall Tradesignal Ltd. be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, or of or in connection with this code or the use of this code.


porta. sem, tristique elementum Lorem eleifend non eget id,