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 26, 0 bars in 1500 trades! 🙂
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 July 2008 – Jan 2014.
The results above are £1 Per Point, £1000 Start and 1.5 Spread.
I am live trading this with real money with minimum stakes to test. IG have now reduced the PPP from £2 to £1 just recently. This is very handy for forward live testing.
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 weekend.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
//------------------------------------------------------------------------- // Main code : Breakout ProOrder EN DAX //------------------------------------------------------------------------- // We do not store data until the system starts. // If it is the first day that the system is launched and if it is afternoon, // it will wait until the next day for defining sell and buy orders. //All times are UK Time Zone DEFPARAM PreLoadBars = 0 // Position is closed at 20h00 PM DEFPARAM FlatAfter = 200000 // No new position will be initiated after the 16:00PM candlestick. Any existing orders cancelled at 16:30pm LimitHour = 161500 // Market scan begin with the 15 minute candlestick that closed at 8:30AM StartHour = 081500 // The 24th-31st days of December will not be traded because the market closes early. 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 = 074500 then //PositionSize = max(1,1+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume PositionSize = 1 //constant trade volume over the time endif MaxAmplitude = 170 MinAmplitude = 22 OrderDistance = 9 PourcentageMin = 19 // 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 + 1](High) LowLevel = Lowest [IntradayBarIndex - DayStartIndex + 1](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 TARGET PPROFIT 190 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Great work! thanks for sharing
Just asking, do I have to set a profit stop?
Love the comments preceding each line / block of code … so useful for the likes of me who find it difficult (near impossible often) to interpet complex code written by others.
I know full explanatory comments are more time consuming, so a big thank you from me goes to Cosmic, good work!
GraHal
Aha I now see the good discipline has spread from our Master – Nicolas via the original ‘CAC Breakout Bot’
Thank You Nicolas
From Grasshopper GraHal 🙂
@Pjotterd You don’t have to but you can uncomment that part, Line 112. I am not running it with one.
@GraHal Yes all Nicolas’ hard work. Simply a port from me.
A shame today’s fall was not captured but it fell outside of spec. Must be trusting in the backtest and IN/OUT sample. A good week overall for this strat though so cannot complain.
Hi, I am going to use this system tomorrow with £1 trades. I’ll post my results. Do you have a direct email by any chance?
Ollie
Hi … Thanks a lot for sharing this strategy. I have backtested this and works fine on DAX. Only concern is bigger position size. It does not seem to behave well if I have a position size of 10 (for e.g.) Can you suggest if this strategy is supposed to work only with small position sizes ?
Hi Vish,
All works ok here. I started it just now with 10k starting pot and £10pp. Ends up at £104,000 from Sept 2008 to present day.
Thanks Cosmic. It works for me too. That was a silly mistake. Last week went quite well with this strategy on live trading. Anyone here likes to share to share results how they are getting on with it in live environment.
Hi Vish, Yes it was a good Thursday and Friday where between DAX and DOW breakout +800 points were added. As we know there could be drawdown but it’s nice to have a bit of a buffer built up now.
I cannot get my time conversions correct for Sydney Australia to get any data for this code.
Not sure what i am doing wrong
@JadeDB What times are you putting in?
I tried this one out recently, and wasn’t profitable for me.
Yes, not great lately. I stopped this live at the end of last year. Will wait to see when the right time is to put it back on. Just shows you that even following all the rules to avoid curve fitting etc, algo’s can still bite you!