Doctrading

Simple "Dax Breakout" trading strategy code

Category: Strategies By: Doctrading Created: April 8, 2016, 8:33 PM
April 8, 2016, 8:33 PM
Strategies
37 Comments
Simple "Dax Breakout" trading strategy code

Hello everyone,
Here is a small breakout strategy.
Here, I tested with the following settings:

– Range (channel) defined between 09H at 9H30

– On the DAX, 15 minute timeframe

– We play the breakout of high / low of the range

– Stop Loss: the other side of the range

– Take Profit: equal to the stop loss

As you can see, the code is simple.

The backtest is positive, even if it is not optimal.

Indeed, the max drawdown of € 6,548 (for an initial bet of € 10,000), for a capital gain of 51.80% per year. is too high.

We can decrease the contract size by 2 (max drawdown of € 3,274 for a capital gain of 25.90% per year), but the capital growth curve is still quite irregular.

However, this strategy seems logical and reliable, so I think there is much way to improve it.

It also works on CAC40 (or may some other indices).

But paradoxically it doesn’t work well on forex (I wanted to write it for forex, in order to use it automatically).

Defparam cumulateorders = false
Defparam flatafter = 180000

n = 1

IF Time = 093000 THEN
 haut = highest[2](high)
 bas = lowest[2](low)
 amplitude = haut - bas
 achat = 0
 vente = 0
ENDIF

if Time > 093000 AND Time <= 180000 THEN

 IF achat = 0 THEN
  buy n share at haut stop
 ENDIF

 IF vente = 0 THEN
  sellshort n share at bas stop
 ENDIF

ENDIF

If longonmarket THEN
 achat = 1
ENDIF

IF shortonmarket THEN
 vente = 1
ENDIF

set stop ploss amplitude
set target pprofit amplitude

 

Download
Filename: BREAKOUT-DAX.itf
Downloads: 306
Doctrading
Doctrading Master
Hello, I'm Marc. Nice to meet you.
Author’s Profile

Comments

Dave
10 years ago
#

Apologies - only just learning the site layout.

Maybe you could delete the post?

Dave
10 years ago
#

Hi, I'm new to coding and have been trying to modify the code a little to backtest an idea I have but am struggling!.my idea is to take the first 8.00 uk m15 candle and create a sell order 25 points above the high and a buy order 25 from the low incorporating a simple 25 sl and 50tp.Any help would be greatly appreciated.

Regards

Dave

Nicolas
10 years ago
#

Better use the forums for coding assistance please. You'll get more results there for sure.

Hockeytrader
10 years ago
#

Hey. Been comparing the strategys performance versus the DAX volatility index. i've not done all 100 000 bars yet but so far the strategy is profitable when the $VDAX is somewhere between 15 & 25. Gonna work on this tonight and see if a can give you some kind of report.

cupcake
10 years ago
#

so I've tried to amend the OP's code to look at a smaller range for my breakout, but I can't get it to take any trades at all

Defparam cumulateorders = false
Defparam flatafter = 180000

n = 1

IF Time = 090501 THEN
phigh = highest[2](high)
plow = lowest[2](low)
amplitude = phigh - psell
pbuy = 0
psell = 0
ENDIF

if Time > 090501 AND Time <= 180000 THEN

IF pbuy = 0 THEN
buy n share at phigh stop
ENDIF

IF psell = 0 THEN
sellshort n share at plow stop
ENDIF

ENDIF

If longonmarket THEN
pbuy = 1
ENDIF

IF shortonmarket THEN
psell = 1
ENDIF

set stop ploss amplitude
set target pprofit amplitude

 

Hockeytrader
10 years ago
#

Thanks. Will try it out.

Doctrading
10 years ago
#

 

Just don't consider the // timeframe   and // 05H to 09H   breakout.
It was from an ancient london open breakout code.

Doctrading
10 years ago
#

The code should look like this : 

Defparam cumulateorders = false

// Timeframe : H1
// HORAIRES DU BREAKOUT : 05H à 09H

IF TIME = 080000 THEN
HAUT = highest[1](high)
BAS = lowest[1](low)
achatjour = 0
ventejour = 0
amplitude = haut-bas
ENDIF

Ctime = time >= 080000 AND time <= 120000


IF Ctime THEN
IF achatjour = 0 THEN
buy at HAUT + 1 stop
ELSIF ventejour = 0 THEN
sellshort at BAS - 1 stop
ENDIF
ENDIF

IF longonmarket THEN
achatjour = 1
ENDIF
IF shortonmarket THEN
ventejour = 1
ENDIF



set stop loss amplitude
set target profit amplitude

But there is some issues : 

  • I did't set yet that if the first order is winning, there will be no second order
  • it is winning without spread... but loosing with 1 point spread

Feel free to improve this code.
regards,

Hockeytrader
10 years ago
#

Been testing the code for four weeks now. One optimisation i've been thinking about is to open a position when a bar closes over/under day h/l. who knows how that code would look?

cupcake
10 years ago
#

if the first hits the target then that's the only trade.

If doesn't hit target, then opens the reverse trade when stopped.

No trades at all after 12pm if long or short hasn't triggered

Doctrading
10 years ago
#

I will try later.
If it is profitable, I will share the code.

Do you take 2 trades a day even if the first is winning ? Or only one ?
Regards,

cupcake
10 years ago
#

it's the first 5m bar on the 8am GMT open.

Manually I would go long 2 points above the high of that first bar, with a stop 2 points below the low, and visa versa for the short entry.

I'm just struggling to code it at the moment.

Doctrading
10 years ago
#

Hello,

Do you just consider the first 5min bar at 9AM as the range ?

Yes, it is quite easy to backtest, but results will not be good. Because it is a too small timeframe, because of slippage, because of spread.

Regards,

cupcake
10 years ago
#

Hi, I'm trying to get my own system together that is very similar to the OP's.

It's in essence a range breakout, but my range is the opening 5m bar of the day.

stops and targets are similar theory to the OP's as well,  Stop Loss: the other side of the range, Take Profit: equal to the stop loss

I just can't for the life of me amend this code to work, or get my own code.

Is there anyone that's able to help me with this at all?

 

Thank you in advance.

 

Doctrading
10 years ago
#

Hello, it is still possible, but I don't like martingale.

Hockeytrader
10 years ago
#

I've had this thought that if the first trade goes wrong and we end up with a loose. Is it possible to make the second trade double size?

Glen Marquis
10 years ago
#

Only exit at other side of the 9.00-9.30 range, Dax moves far more "usually" than that!
Perhaps try this with a 50+ target & 20 point stop trail.

raj
raj
10 years ago
#

Hi

Thanks for sharing. I have tried to use this code for a strategy I want to test on forex. The idea is to create an overnight range from the previous 8 hours and trade the breakout of this range from 9am onwards. Below is the code just for the long side of the stagey with 15min bars, hence (32) as this is 8h. I want it to go flat at 13:00, have added a trailing stop and a pip target. This are not optimised in any way, just first ideas to test.

Anyhow, it does not seem to work. For some reason it does not take trades on certain days and sometimes take multiple trades on after another. I think one of the problems is the range is constantly being updated from the previous 32 bars, whereas I want it set rigid after 9am (highest/lowest 1am-9am). I thought the part 'IF time = 090000' would set this but not 100% sure, I am very new to this.

Thanks in advance!

Defparam cumulateorders = false

Defparam flatafter = 130000

n = 1

IF Time = 090000 THEN
top = highest[32](high)
long = 0
ENDIF

if Time >= 090000 AND Time <= 130000 THEN

IF long = 0 THEN
buy n share at top stop
ENDIF

ENDIF

If longonmarket THEN
long = 1
ENDIF

SET STOP pTRAILING 15
set target pprofit 30

Doctrading
10 years ago
#

"Haut" = "high"

"Bas" = "low"

"Achat & Vente" = "Buy & Sell"

Google Translate is your friend ;)

Hockeytrader
10 years ago
#

Haha, thanks for the help! 

Doctrading
10 years ago
#

Hello Hockeytrader,

I don't understand you, the code is already in English, isn't it ?

Hockeytrader
10 years ago
#

Hi! Thanks for answer. Haut, bas, achat & vente are the words i'm thinking about.

Hockeytrader
10 years ago
#

Hi! Thanks for this code. Im willing to make some adjustments but before that i need the code to be translated to english. Somebody who can help?

Doctrading
10 years ago
#

Hello,

Of course this strategy needs improvement.

It's only good after 2014 (don't forget to backtest it with spread ! the screenshot doesn't show spread).

Trailing stop would also be a nice idea. But first I test on several years with take profit, in order to see if it's viable.

Personnage, I wouldn't use this one in real trading, as it is profitable only since 2014.

Jan
Jan
10 years ago
#

This morning the system startet and worked good whit 1 contract. halfe an houre ago i deleted the system and added a new one whit n=2.

After a few minutes it started too sell 2 contracts.  it wasn't in the ranges of 09:00 houres 09:30.  ho is this possible?

 

Jan
Jan
10 years ago
#

Thanks for the quick answer.

Is it allso an idea to add a trailing stop extra to the system. start at the take profit zone?

 

Nicolas
10 years ago
#

It is Doctrading's strategy, maybe he could answer better than me to this question :) Sometimes trailing stop just kill profit more than let it run, it needs some test here!

ProRealCode ProRealCode
Loading...