Derek

Beating the S&P 500 – Long Term

Category: Strategies By: Derek Created: February 27, 2017, 3:12 PM
February 27, 2017, 3:12 PM
Strategies
11 Comments
Beating the S&P 500 – Long Term

Hello!

This is my first submission to the strategy section of this site. My goal is to build filters for market regimes that provide the biases for more short term trading strategies. This submission is a byproduct of my research:

Following is a long term system based on a very simple timing model for capital preservation.

Timeframe is monthly and 2 indicators are used:

  • John Ehlers Supersmoother at the standard value of 8.
  • A 40 period simple moving average. The SMA has been improved and you can check it is robust to a range of variations.

The system is always on the market. Either long or short.

It doesn’t trade very often and it is not supposed to. The very upside of this model is not the profit but the maximum risk exposure of 13.22%! Maximum drawdown is 2.58 percent!

If you think this is interesting, please critique thoroughly because it will be highly appreciated.

DEFPARAM CumulateOrders = false
DEFPARAM PRELOADBARS = 40

//John Ehlers’ "Super Smoother", a 2-pole Butterworth filter combined with a 2-bar SMA that suppresses the Nyquist frequency:
Period = 8
Data = Close
PI = 3.14159
f = (1.414*PI) / Period
a = exp(-f)
c2 = 2*a*cos(f)
c3 = -a*a
c1 = 1 - c2 - c3
if barindex>Period then
 S = c1*(Data[0]+Data[1])*0.5 + c2*S[1] + c3*S[2]
endif

c1 = (close > S)
c2 = (S > S[1])

IF c1 AND c2 THEN
 EXITSHORT 1 CONTRACT AT MARKET
 BUY 1 CONTRACT AT MARKET
ENDIF

c3 = (close CROSSES UNDER Average[40](close))

IF c3 THEN
 SELL  AT MARKET
 SELLSHORT 1 CONTRACT AT MARKET
ENDIF

 

Download
Filename: Beating-the-SP-500.itf
Downloads: 466
Derek
Derek Veteran
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

gatowman
7 years ago
#

Hallo Derek, ich bin neu hier, wo finde ich die beiden Indikatoren? kansst du sie als itf posten, bitte? ich möchte die Indis zur Kontrolle im Chart sehen, danke. gatowman

Derek
10 years ago
#

Clarification:

Automatic rollover will be into the nearest forward but I prefer the farthest forward because of the costs. So I rollover manually if it is feasible.

Derek
10 years ago
#

It's a CFD on the futures contract. That's why there is no commission and IG calls it a Forward.

IG offers a automatic rollover into the next future/forward but this will cost more spread or slippage. For example when trading the US500 Jun-17 contract in January with minimum contract size this was no problem at all. But it could be.

With long-term contracts it's less of a problem though (but should not be neglected).

DEIO
10 years ago
#

hi Derek,

so you mean that you are using CASH contract as US 500 Cash (mini or full doesn't matter)  and this

kind of CFD doesn't involve nightly payments on the cash account ?

When you say that you have to do this manually, what exactly you do and when it is necessary  ?

thx for the patience.

bye

 

Derek
10 years ago
#

Hi DEIO,

since I trade with IG CFDs overnight commissions can be excluded from the equation if forward contracts are used.

Especially on the S&P 500 you can go for a half a year without rolling over once. You have to do this manually though.

DEIO
10 years ago
#

Hi,

just a question about the long term strategies (like this):

did you test how much the equity line is modified by overnight interest ?

I'm very interested to know what are your results in such sense.

Thx a lot.

bye

Derek
10 years ago
#

Hello arcane,

you are right.

Starting capital = 10.000,-€

Spread = 1

Timeframe : Monthly

Derek
10 years ago
#

Good question. Especially the special types of bear markets in the US can be misleading. 

The exact same system even outperforms the Nikkei 225 unfortunately the risk is a lot higher and the entry in the bear market is a disaster. In cases like these I suggest to add another rule.

IF c1 AND c2 and close crosses over Average[40](close) THEN
EXITSHORT 1 CONTRACT AT MARKET
BUY 1 CONTRACT AT MARKET
ENDIF

This will reduce drawdowns a lot.

bertrandpinoy
7 years ago
#

BONSOIR j ai tenté votre modification mais PRT ne l accepte pas "erreur de syntax" pouvez vous m aider a utiliser le code avec votre modif? merci cordialement

arcane
10 years ago
#

For a program, please specify

the support
The spread
The time unit.

You need to do this at the beginning of the code.

Thank you.

Nicolas
10 years ago
#

As long as it beat buy and hold, it's interesting! As you wrote it, it can be used to find the bias of the market regime. Could it be adapted to other securities?

ProRealCode ProRealCode
Loading...