Nicola's ProOrder Breakout on any Index
Forums › ProRealTime English forum › General trading discussions › Nicola's ProOrder Breakout on any Index
- This topic has 10 replies, 4 voices, and was last updated 8 years ago by Nicolas.
-
-
06/07/2016 at 3:58 PM #8965
Hi, I have done a small change to the famous TS created by Nicolas posted here:
http://www.prorealcode.com/blog/automated-breakout-trading-strategy-french-cac40/
I have removed the MM for the moment just to compare the results and fixed the variables to a % value and not the fixed one choosen by Nicolas.
The part of the code that I have changed is this:
123456789if time = 084500 thenPositionSize = 3 //constant trade volume over the timeendifIndexValue = closeMaxAmplitude =IndexValue* 0.01318MinAmplitude = IndexValue * 0.0025OrderDistance = IndexValue * 0.0009PourcentageMin = 30Here some results run with normal IG market spreads.
Look what happen with Dax and MM 🙂
For this Ts i Propose a different MM. I do not increase the number of contracts but as soon as the first Ts gains 1000 euro I start it on a second index. When also the second index gain 1000 euro I run it on a third index… etc… Nicolas, what do you think about this idea?
Here the whole code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107// 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 ordersDEFPARAM PreLoadBars = 0// Position is closed at 7h45 PM, frenh time (in case of CAC40 trading)DEFPARAM FlatAfter = 194500// No new position will be initiated after the 5h00 PM candlestickLimitHour = 171500// Market scan begin with the 15 minute candlestick that closed at 9h15 AMStartHour = 091500// The 24th and 31th days of December will not be traded because market close before 7h45 PMIF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THENTradingDay = 0ELSETradingDay = 1ENDIF// Variables that would be adapted to your preferencesif time = 084500 thenPositionSize = max(2,2+ROUND((strategyprofit-1000)/1000)) //gain re-invest trade volume//PositionSize = 3 //constant trade volume over the timeendifIndexValue = closeMaxAmplitude =IndexValue* 0.01318 //set 58 for less risk 32.5 for more riskMinAmplitude = IndexValue * 0.0025 //11OrderDistance = IndexValue * 0.0009 //4PourcentageMin = 30//IndexValue * 0.00681 //30// Variable initilization once at system startONCE StartTradingDay = -1// Variables that can change in intraday are initiliazed// at first bar on each new dayIF (Time <= StartHour AND StartTradingDay <> 0) OR IntradayBarIndex = 0 THENBuyTreshold = 0SellTreshold = 0BuyPosition = 0SellPosition = 0StartTradingDay = 0ELSIF Time >= StartHour AND StartTradingDay = 0 AND TradingDay = 1 THEN// We store the first trading day bar indexDayStartIndex = IntradayBarIndexStartTradingDay = 1ELSIF 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 definedIF BuyTreshold = 0 OR SellTreshold = 0 THENHighLevel = Highest[IntradayBarIndex - DayStartIndex + 1](High)LowLevel = Lowest [IntradayBarIndex - DayStartIndex + 1](Low)// Spread calculation between the higher and the// lower value of the instrument since StartHourDaySpread = HighLevel - LowLevel// Minimal spread calculation allowed to consider a significant price breakout// of the higher and lower valueMinSpread = DaySpread * PourcentageMin / 100// Buy and sell tresholds for the actual if conditions are metIF DaySpread <= MaxAmplitude THENIF SellTreshold = 0 AND (Close - LowLevel) >= MinSpread THENSellTreshold = LowLevel + OrderDistanceENDIFIF BuyTreshold = 0 AND (HighLevel - Close) >= MinSpread THENBuyTreshold = HighLevel - OrderDistanceENDIFENDIFENDIF// Creation of the buy and sell orders for the day// if the conditions are metIF SellTreshold > 0 AND BuyTreshold > 0 AND (BuyTreshold - SellTreshold) >= MinAmplitude THENIF BuyPosition = 0 THENIF LongOnMarket THENBuyPosition = 1ELSEBUY PositionSize CONTRACT AT BuyTreshold STOPENDIFENDIFIF SellPosition = 0 THENIF ShortOnMarket THENSellPosition = 1ELSESELLSHORT PositionSize CONTRACT AT SellTreshold STOPENDIFENDIFENDIFENDIF// Conditions definitions to exit market when a buy or sell order is already launchedIF LongOnMarket AND ((Time <= LimitHour AND SellPosition = 1) OR Time > LimitHour) THENSELL AT SellTreshold STOPELSIF ShortOnMarket AND ((Time <= LimitHour AND BuyPosition = 1) OR Time > LimitHour) THENEXITSHORT AT BuyTreshold STOPENDIF// Maximal risk definition of loss per position// in case of bad evolution of the instrument priceSET STOP PLOSS MaxAmplitudeDavid
1 user thanked author for this post.
06/07/2016 at 4:11 PM #8969Hi David, thanks for attributing me this nice trading strategy… but it is not mine 🙂 This strategy is an example of ProOrder code and its part of the official documentation.
Anyway, I don’t understand the factors you set on the first part of the code? (Max and Min amplitude, etc..) How do you set them? (from line 28 to 30)
About launch multiple instance of the same strategy on different index, well.. why not!
06/07/2016 at 4:29 PM #8970They are choosen from the original.
In the CAC you have maxAmplitude of 58. This mean if the CAC index is around 4400 you divide 58 by 4400 and you get 0.01318 (%).
1MaxAmplitude <span class="token operator">=</span>IndexValue<span class="token operator">*</span> <span class="token number">0.01318</span>06/07/2016 at 4:42 PM #897106/07/2016 at 4:49 PM #8972Oh ok! so this is an universal factor made of the amplitude 58 from the CAC40 strategy. That’s clever to have it done this way. But it involves too that all instrument have the same behaviour as the CAC40 index, so maybe you should find an Amplitude that suit well for all instrument instead. That’s the beginning of something..
06/08/2016 at 8:38 AM #9011I Nicolas, here the main problem…
I could easily find the max amplitude that fit better for all… but… it will be curve fitted!
How could I find it to be sure that it is not curve fitted?
I could do an easy forward test:
- I find the best values for only one index (you already did it. It is 58 for the CAC : -) )
- I test in on other periods (instead of periods I change index)
- It gives good performance also on other indexes.
- The value 58 it is not curve fitted!!
why should I now make the mistake to find the perfect one on the past that could not work in the future?
Second, can someone that has 200.000 bars test this TS? It would be nice to have it for a bigger period.
Really easy test… take my code.
for Dax and cac put spread 1 and 2 contracts
for Mib put 1 contract and 8 spread
for eurostocks put 1,5 spread and 3 contracts
06/08/2016 at 8:47 AM #901306/08/2016 at 4:26 PM #9071It would be curve fitted on 5 curves… don’t you think so?
06/08/2016 at 5:52 PM #908506/08/2016 at 5:53 PM #908806/08/2016 at 7:20 PM #9096David, trying to avoid over-fit is very nice but keep in mind that everything in life is over-fit .. from the resistance of your car’s tires to the length of spaghetti.. Human tied to make things better in the future from what they learned from the past and maybe we have to deal with it in trading and maybe over-fit is a part of what would be automated trading.
I believe that there is no good or bad ways to trade, I used to say that the best strategy is the one that make you a profitable trader.. therefore, apart of learning purpose and understanding, the crusade against over-fitting is a dead end, IMO .. To be clear: don’t over-fit but don’t spend too much time to avoid over-fit.
We only have 3 sets of datas to make proof of concept for any trading strategy : time and price (and volumes .. but that’s not the case here). So, somehow, every equity curve of any trading strategy are curve fitted in various ways. Remember I wrote somewhere in our past exchange about this subject, that the first bias we introduce that over-fit our trading strategy concept is: make gain, no loss.
-
AuthorPosts
Find exclusive trading pro-tools on