ProRealCode - Trading & Coding with ProRealTime™
I have been working on getting some more reliable auto strategies incorporated in to my trading along side the manual stuff I do.
I’m testing Nicolas’ code for CAC breakout on different markets at the moment due to the fact that with 200k units and the 15TF you can get 8-9 years of data for increased confidence + the fact of no 0 bars/no fake profits. Prior to this I was using 1min TF to eliminate 0 bars/fake profits on some breakout auto trades that I had made for the major indices but with only 18 months of data, of course the forward testing did not match up to the backtest and I lost confidence.
I’ve tried a few markets but the two I focused on at the moment are DAX and EUR/USD.
I optimised these with 2/3 of the data as suggested to avoid curve fitting. The results are below.
I can give the basic changes here or upload the ITF’s if any one is interested.
Has anyone else had success porting this one to different markets?
Have you calculated with spread or without?
With 1.5 point spread for DAX and 1.4 for EUR/USD
What have you changed ?
can you upload the itf ?
Nice work cosmic. I know some people have successfully adapted the strategy to other markets already. But I’ve never had the chance to investigate more their codes.
I’m pleased to know that you made optimization with In/Out sample, that’s a lot of work to do manually 👌.
So yes, this topic could be the new central topic for the breakout strategy experiments! Your modified code is welcome! I’ll do my best to help here. Like I said before I believe in this strategy.
I think I tested it on DAX as well, and the conclusion was that It looked promising. I need to dig in my notes to see where and why I did not pay any further attention for this. Most likely it drowned among all the other codes that I was testing. I fond these notes and Screendumps:
“Looks pretty good on DAX 5 min” unfortunately I did not get the equity curve.
Edit- when I look deeper into this, It was not Nicolas’ code, but Reiners. I seem to remember testing the CAC code. I need to look deeper in my notes
Cheers Kasper
Here is the DAX one. Feel free to take a look at that first while I tidy up EUR/USD. You will see that I added a pprofit limit at the bottom of the code as this improved things slightly. There are some alternate values that are commented that I played around with.
//-------------------------------------------------------------------------
// Main code : Breakout ProOrder EN DAX
//-------------------------------------------------------------------------
// 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
//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 16h00 PM candlestick
LimitHour = 161500
// Market scan begin with the 15 minute candlestick that closed at 8h15 AM
StartHour = 081500
// 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 = 074500 then
//PositionSize = max(2,2+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume
PositionSize = 2 //constant trade volume over the time
endif
MaxAmplitude = 140 //140 //160
MinAmplitude = 24 //24 //15
OrderDistance = 7 //7 //10
PourcentageMin = 30 //30 //32
// 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//190
EUR/USD
// 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
//All times are in UK timezone
DEFPARAM PreLoadBars = 0
// Position is closed at 20h30 PM
DEFPARAM FlatAfter = 203000
// No new position will be initiated after the 19h45 PM candlestick
LimitHour = 200000
// Market scan begin with the 15 minute candlestick that closed at 7h45 AM
StartHour = 074500
// 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 = 073000 then
PositionSize = 1
//max(2,2+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume
//PositionSize = 2 //constant trade volume over the time
endif
MaxAmplitude = 85 //85 //140
MinAmplitude = 9 //9 //20
OrderDistance = 0 //0 //-4
PourcentageMin = 34 //34 //30?
// 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 100
Hi all,
thanks! but can anyone guide me which should be my settings for the Timezone? In PRT I set as GMT+8 which is Singapore.
in the Code, how to change it? I kinda confuse how to look at timezone 🙁
thanks in advance!
UK timezone are GMT+1(summertime) so I think you need to add 7 hours everywhere there is a time involved. To be sure try and change things according to the world timezones.
Hi Elsborg,
Thanks! Had been busy lately.
I had tried to change but when I backtest against EURUSD, there’s no result. Any idea?
// 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
//All times are Changed to SG timezone
DEFPARAM PreLoadBars = 0
// Position is closed at 20h30 PM
DEFPARAM FlatAfter = 033000
// No new position will be initiated after the 19h45 PM candlestick
LimitHour = 030000
// Market scan begin with the 15 minute candlestick that closed at 7h45 AM
StartHour = 144500
// 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 = 143000 then
PositionSize = 1
//max(2,2+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume
//PositionSize = 2 //constant trade volume over the time
endif
MaxAmplitude = 85 //85 //140
MinAmplitude = 9 //9 //20
OrderDistance = 0 //0 //-4
PourcentageMin = 34 //34 //30?
// 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 100
I did the porting of nicolas CAC breackout on dax but only changing his values and parameter to fit on dax without any optimization. You may find a thread regarding this.
what parameters have you optimized? Which is the InSample and the Outof sample period?
Thanks
David
Hey David, nice to see you back! Hope everything’s ok on your side.
There’s not much variables to change in this strategy, because it doesn’t rely at all on indicator. I think the only optimized values are these ones:
MaxAmplitude = 85 //85 //140
MinAmplitude = 9 //9 //20
OrderDistance = 0 //0 //-4
PourcentageMin = 34 //34 //30?
Since it’s Cosmic topic, I let him answer to this question more precisely.
CAC Breakout ported to other markets
This topic contains 37 replies,
has 10 voices, and was last updated by Despair
8 years, 7 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 08/18/2016 |
| Status: | Active |
| Attachments: | 6 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.