Cosmic1

DOW Breakout 15Min

Category: Strategies By: Cosmic1 Created: September 6, 2016, 1:08 PM
September 6, 2016, 1:08 PM
Strategies
52 Comments
DOW Breakout 15Min

Firstly, a big thank you to Nicolas for this great site and for originally introducing us to the CAC Breakout using the same code here.

I set about testing this strategy on other markets due to the fact you can backtest 8 years of data with 200,000 units on the 15Min time-frame. The other massive plus is no fake profits and only 9, 0 bars in 1700 trades! 🙂

The DOW is slightly different to the CAC and DAX breakout. It did not like the first 30 min range but prefers the first hour range BUT we exclude the first 15min candle as you can see from the modifications to the code.

In this version I am using a fixed position size but you can activate the re-invest system if you are happy with that. It makes for an interesting ride!

I stuck to the rules of not over optimising/curve fitting by using an IN/OUT sample as documented here. This ran from Jun 2009 – May 2014.

The results above are £1 Per Point, £1000 Start and 1.8 Spread.

I am live trading this with real money with minimum stakes to test.

All times in the code are UK so please adjust to your timezone.

I have some more of these ported to other markets but need to spend a little more time getting them right before posting in the library. Expect them soon.

I have not had enough time to test different time frames. Maybe I will try that next if time allows.

Good luck and enjoy your trading.

// We do not store datas until the system starts.
// If it is the first day that the system is launched and if it is afternoon,
// it will be waiting until the next day for defining sell and buy orders

//UK TIME ZONE

DEFPARAM PreLoadBars = 0

// Position is closed at 20:30
DEFPARAM FlatAfter = 203000

// No new position will be initiated after the 19:45 candlestick.
LimitHour = 200000

// Market scan begin with the 15 minute candlestick that closed at 15:30
StartHour = 151500

// The 24th and 31th days of December will not be traded because market close before 7h45 PM
IF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN

TradingDay = 0
ELSE
TradingDay = 1
ENDIF

// Variables that would be adapted to your preferences
if time = 144500 then

//PositionSize = max(1,1+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume
PositionSize = 1 //constant trade volume over the time
endif

MaxAmplitude = 160
MinAmplitude = 20
OrderDistance = 4
PourcentageMin = 35

// Variable initilization once at system start
ONCE StartTradingDay = -1

// Variables that can change in intraday are initiliazed
// at first bar on each new day
IF (Time <= StartHour AND StartTradingDay <> 0) OR IntradayBarIndex = 0 THEN
BuyTreshold = 0
SellTreshold = 0
BuyPosition = 0
SellPosition = 0
StartTradingDay = 0
ELSIF Time >= StartHour AND StartTradingDay = 0 AND TradingDay = 1 THEN

// We store the first trading day bar index
DayStartIndex = IntradayBarIndex
StartTradingDay = 1
ELSIF StartTradingDay = 1 AND Time <= LimitHour THEN

// For each trading day, we define each 15 minutes
// the higher and lower price value of the instrument since StartHour
// until the buy and sell tresholds are not defined
IF BuyTreshold = 0 OR SellTreshold = 0 THEN
HighLevel = Highest[IntradayBarIndex - DayStartIndex + 2](High)
LowLevel = Lowest [IntradayBarIndex - DayStartIndex + 2](Low)

// Spread calculation between the higher and the
// lower value of the instrument since StartHour
DaySpread = HighLevel - LowLevel

// Minimal spread calculation allowed to consider a significant price breakout
// of the higher and lower value
MinSpread = DaySpread * PourcentageMin / 100

// Buy and sell tresholds for the actual if conditions are met
IF DaySpread <= MaxAmplitude THEN
IF SellTreshold = 0 AND (Close - LowLevel) >= MinSpread THEN
SellTreshold = LowLevel + OrderDistance
ENDIF
IF BuyTreshold = 0 AND (HighLevel - Close) >= MinSpread THEN
BuyTreshold = HighLevel - OrderDistance
ENDIF
ENDIF
ENDIF

// Creation of the buy and sell orders for the day
// if the conditions are met
IF SellTreshold > 0 AND BuyTreshold > 0 AND (BuyTreshold - SellTreshold) >= MinAmplitude THEN
IF BuyPosition = 0 THEN
IF LongOnMarket THEN
BuyPosition = 1
ELSE
BUY PositionSize CONTRACT AT BuyTreshold STOP
ENDIF
ENDIF
IF SellPosition = 0 THEN
IF ShortOnMarket THEN
SellPosition = 1
ELSE
SELLSHORT PositionSize CONTRACT AT SellTreshold STOP
ENDIF
ENDIF
ENDIF
ENDIF

// Conditions definitions to exit market when a buy or sell order is already launched
IF LongOnMarket AND ((Time <= LimitHour AND SellPosition = 1) OR Time > LimitHour) THEN
SELL AT SellTreshold STOP
ELSIF ShortOnMarket AND ((Time <= LimitHour AND BuyPosition = 1) OR Time > LimitHour) THEN
EXITSHORT AT BuyTreshold STOP
ENDIF

// Maximal risk definition of loss per position
// in case of bad evolution of the instrument price
SET STOP PLOSS MaxAmplitude
//SET TAGRGET PPROFIT //70 //160

Download
Filename: ale.png
Downloads: 161
Download
Filename: compare3.png
Downloads: 181
Download
Filename: compare2.png
Downloads: 273
Download
Filename: Breakout-ProOrder-DOW.itf
Downloads: 693
Cosmic1
Cosmic1 Senior
Operating in the shadows, I hack problems one by one. My bio is currently encrypted by a complex algorithm. Decryption underway...
Author’s Profile

Comments

abacus23
6 years ago
#

Hi, I have been trading this strategy and it seems to work quite well recently. Is there anyway to insert a piece of code, to only trade, accordingly to yesterday price action. I.e: if yesterday was up, only longs and if yesterday was down, only shorts? I did insert a piece of code, but it can't backtest it, because there is only ever one 2100 line. Sorry, the ADD code did not work. defparam drawonlastbaronly=true if time=210000 then value=close endif drawhline(value) return

rejo007
9 years ago
#

hello, anybody use thi strategy for a long time? thanks

Cosmic1
9 years ago
#

Lets discuss here: https://www.prorealcode.com/topic/cac-breakout-ported-to-other-markets/

sammut
9 years ago
#

Hey Cosmic, I am just in the process of re-evaluating my variables due to, as you say, some recent choppy rides. The parameters I optimise are below:

  • MinAmplitude
  • OrderDistance
  • PourcentageMin
  • StartHourStep
  • RangeExtendStep

I dont change MaxAmplitude as I want to fix my maximum risk at this stage. I optimise additional variables StartHourStep and RangeExtendStep.
I am just realising that I am not able to attach my code in this post for some reason. If you send over your email I can forward my code (.itf files) for you to check out and discuss

Cosmic1
9 years ago
#

Looks like a good bit of code. I will take a look later. I'd really like to get this algo back on and running but over the last 10 months or so it has been flat and choppy. Same story with the DAX. I stopped it a few months ago now and have looked since but can't find a set of variables or equity curve that I'm happy with. What variables are you running?

sammut
9 years ago
#

I have attached my version of your DOW breakout strategy. Main bits for DLS adjustments are as follows:

IF ((Month = 3 and Day > 7) and (Month = 3 and Day < 15)) or ((Month = 11 and Day >= 1) and (Month = 11 and Day < 8)) THEN
//Period over which Daylight savings takes place, no trading during this time
TradingDay = 0
DLS = 0
elsif (Month = 3 and Day >= 15) or ((Month > 3) and (Month < 11)) THEN
//DLS applies as New York is forward an hour during this period
// New York time is (GMT - 4)
DLS = -10000
else
// No DLS
// New York time is (GMT - 5)
DLS = 0
endif


LimitHour = 204500 + DLS

I also use different variables in my code, probably as I do not have PRT professional yet and have limited data to test on :(

Thanks for posting your code Cosmic, it has been the first algo I have traded live with!

Cosmic1
9 years ago
#

Hey Sammut,

I have never done this but I thought about it before but didn't do anything about it! I just adjust manually at those times of the year that we mismatch with the US. It does of course affect the backtest slightly.

How do you achieve it in your code? I would like to update the blackest to take account of this.

@Nicolas, any insight in to this?

sammut
9 years ago
#

Hey Cosmic, 

Do you typically add a daylight savings adjustment in your code when running back tests over multiple years of data? I'm not sure if I'm the only one who does this however I hope I'm not missing out on a simpler way :)

Cosmic1
10 years ago
#

Post the code you are using, will try and figure it out. What broker?

GAMMA
10 years ago
#

I try as per your advise and change the time to usa time still no luck, may be I am doing some thing wrong? please advise ?

Cosmic1
10 years ago
#

Hi Yngve,

Amplitude relates to the range of the price action for the given times stipulated. 45mins in this case. You could relabel these to MinRange and MaxRange.

Orderdistance is the amount of points before the breakout level that the order will be set.

PourcentageMin (should be spelt PercentageMin) is the minimum % of the range that the price has to retrace to validate the breakout. Hope that helps?

Yngve
10 years ago
#

Hi

can someone explan to me what these variables mean

 

MaxAmplitude = 
MinAmplitude = 
OrderDistance = 
PourcentageMin =


or direct me to a later conversatin on this site where it is explaned?

In advance, thank you

/Yngve

Cosmic1
10 years ago
#

DEFPARAM FlatAfter = 153000
LimitHour = 150000
StartHour = 101500
if time = 094500 then

I think that is correct. Test and let me know.

GAMMA
10 years ago
#

THANK YOU , I WILL FIX IT AND RUN THE TEST ,I WILL KEEP POSTED

GAMMA
10 years ago
#

usa /new york

Cosmic1
10 years ago
#

You need to change the time in the code rather than your computer. What timezone are you in?

GAMMA
10 years ago
#

I try to run in prorealtime and it do not give any  profit and loss, I change the time in computer to uk time, may be I am missing some thing

need you advise

GAMMA
10 years ago
#

thank you for detail I open the ac now and used it very soon

Cosmic1
10 years ago
#

From Wikipedia: 


The ProRealTime software embeds a programming language named ProBuilder derived from the language BASIC. It allows the creation of customs indicators, strategies and market scans. It is also used in the ProBacktest, ProScreener and ProOrder modules of ProRealTime.

GAMMA
10 years ago
#

how I can change to C## I used ninja trader all the prog have to me in C##

thank you in advance

GAMMA
10 years ago
#

thank you

GAMMA
10 years ago
#

I AM NEWBE SO I  ASKED THIS QUESTION , CODING IS DONE C++?

GAMMA
10 years ago
#

thank you, I have 2 breakout book in pdf   1.the logical trader by fisher mark b 2.range breakout by toby crabel

Cosmic1
10 years ago
#

Sure, you will need to optimise these variables:

MaxAmplitude = 160
MinAmplitude = 20
OrderDistance = 4
PourcentageMin = 35

And possibly the start times and the amount of candles to look at the range.

Use an IN/OUT sample as suggested in the blog to avoid curve fitting as my description describes.

GAMMA
10 years ago
#

can we used it for other usa index

Cosmic1
10 years ago
#

Sorry wrong pic, DOW...

James
10 years ago
#

hi Cosmic1,  I'm a newbie here, on IG so I can only backtest 10,000 units to May this year, which shows a 50% win/loss ratio and 82% overall gain in that period. Is that what you'd expect on this shorter timefame for backtest ?

Vish
10 years ago
#

Sorry My comments above are meant for DAX breakout strategy

Vish
10 years ago
#

Hi cosmic.... thanks a lot for great strategy. I backtestested this for few days now and went live last night. It doesn't seem to pick any live trades this morning till 11 AM. I am not even sure if this strategy is working at the back end. I am on IG. How do I validate that it is scanning the market and looking for breakout ? Should I just wait and watch ? Hope it can pick trades up anytime before 1615 on daily basis. Response will be very much appreciated. Thanks...

ProRealCode ProRealCode
Loading...