Breakout system for Hong Kong HS50 Cash (HKD10 Mini)
Forums › ProRealTime English forum › ProOrder support › Breakout system for Hong Kong HS50 Cash (HKD10 Mini)
- This topic has 34 replies, 6 voices, and was last updated 7 years ago by BC.
-
-
04/11/2017 at 3:05 PM #31736
This is a Breakout system made for IG market [ Hong Kong HS50 Cash (HKD10 Mini)], Time Frame: 15 mins.
All components were found from PRT forum, the core idea was from Reiner DAX Breakout system and Nicolas trailing stop. Walk forward test was not 100% perfect, Monte Carlo simulation with latest 12-month back test record show HKD$10,000 for the initial capital is ok.
But unfortunally, my live test result was not same as back test, I can’t find what’s wrong with my limited knowledge, hope you guys can help and determine what mistake inside.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146// Market: Hong Kong HS50 Cash (HKD10 Mini)//Time Frame: 15 mins//Remark: HSI night trade start from 2013-04-08, 17:00-23:00,//amended from 2014-11-03, 17:15-23:45// code-parameterDEFPARAM FlatAfter = 234500 //234500// window high/low calculationONCE StartTime = 90000//91500ONCE EndTime = 93000//100000// trading windowONCE BuyTime = EndTimeONCE SellTime = 234500 //234500//SpreadSpread=6//Money managementONCE PositionSize = 1ONCE Capital = 10000ONCE Risk = 5ONCE MaxD = 50 // Quit system if highestc close account balance drop over xx%equity = Capital + StrategyProfitmaxrisk = round(equity*(Risk/100))//Check system account balanceif equity<QuitLevel thenquitendifrecordhighest = MAX(recordhighest,equity)QuitLevel = recordhighest*((100-MaxD)/100)//MA FilterFMA=Average[80](close)SMA=Average[200](close)// calculate breakout box high/low and sl/tpIF Time >= StartTime AND Time <= EndTime THENIF TIME = StartTime THENDailyHigh = HighDailyLow = LowENDIFIF High > DailyHigh THENDailyHigh = HighENDIFIF Low < DailyLow THENDailyLow = LowENDIFsl = min(110,(max(30,((DailyHigh - DailyLow)+Spread))))tp = sl*4PositionSize = min(10,(max(1,abs(round((maxrisk/sl)/PointValue)*pipsize))))TradeCounterLong = 0TradeCounterShort = 0ENDIF//Define the best trading day and time and avoid trading at lunch & teakbreak high spread period, please manual stop system on Hong Kong public hoilday.//LongLOK1=currentdayofweek=1 and ((time>=091500 and time<120000) or (time>=130000 and time<160000) or (time>=171500 and time<230000))LOK2=currentdayofweek=2 and ((time>=091500 and time<120000) or (time>=130000 and time<160000) or (time>=171500 and time<230000))LOK3=currentdayofweek=3 and ((time>=091500 and time<120000) or (time>=130000 and time<160000) or (time>=171500 and time<230000))LOK5=currentdayofweek=5 and ((time>=130000 and time<160000) or (time>=171500 and time<230000))//ShortSOK1=currentdayofweek=1 and ((time>=091500 and time<120000) or (time>=130000 and time<160000) or (time>=171500 and time<230000))SOK2=currentdayofweek=2 and ((time>=130000 and time<160000) or (time>=171500 and time<230000))SOK4=currentdayofweek=4 and ((time>=091500 and time<120000) or (time>=171500 and time<230000))SOK5=currentdayofweek=5 and ((time>=091500 and time<120000) or (time>=130000 and time<160000) or (time>=171500 and time<230000))// Position managementIF Time >= BuyTime AND Time <= SellTime THEN//Long EntryIF Not LONGONMARKET and (LOK1 or LOK2 or LOK3 or LOK5) and close>DailyHigh and FMA>SMA and TradeCounterLong=0 THENBUY PositionSize CONTRACT AT MARKETTradeCounterLong = TradeCounterLong + 1ENDIF//Short EntryIF Not SHORTONMARKET and (SOK1 OR SOK2 OR SOK4 OR SOK5) and close<DailyLow and FMA<SMA AND TradeCounterShort=0 THENSELLSHORT PositionSize CONTRACT AT MARKETTradeCounterShort = TradeCounterShort + 1ENDIF// trailing stop functionONCE trailingStepLong = 0.08// in %ONCE trailingStepShort = 0.08 // in %trailingStartLongInPoints = max(30,(TP/5))trailingStartShortInPoints = max(30,(TP/5))trailingStepLongInPoints = max(10,(tradeprice(1) * trailingStepLong / 100))trailingStepShortInPoints = max(10,(tradeprice(1) * trailingStepShort / 100))// reset the stoploss valueIF NOT ONMARKET THENnewSL = 0ENDIF// manage long positionsIF LONGONMARKET THEN// first move (breakeven)IF newSL = 0 AND close - tradeprice(1) >= trailingStartLongInPoints * pipsize THENnewSL = tradeprice(1) + trailingStepLongInPoints * pipsizeENDIF// next movesIF newSL > 0 AND close - newSL >= trailingStepLongInPoints * pipsize THENnewSL = newSL + trailingStepLongInPoints * pipsizeENDIFENDIF// manage short positionsIF SHORTONMARKET THEN// first move (breakeven)IF newSL = 0 AND tradeprice(1) - close >= trailingStartShortInPoints * pipsize THENnewSL = tradeprice(1) - trailingStepShortInPoints * pipsizeENDIF// next movesIF newSL > 0 AND newSL - close >= trailingStepShortInPoints * pipsize THENnewSL = newSL - trailingStepShortInPoints * pipsizeENDIFENDIF// stop order to exit the positionsIF newSL > 0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF// close positionsIF Time = SellTime THENIF LONGONMARKET THENSELL AT MARKETENDIFIF SHORTONMARKET AND Time = SellTime THENEXITSHORT AT MARKETENDIFENDIF// stops and targetsSET STOP LOSS slSET TARGET PROFIT tpENDIF04/11/2017 at 3:06 PM #3174104/11/2017 at 3:13 PM #3174204/11/2017 at 7:04 PM #31768Your “limited knowledge” give great result as far as I can see on what you are sharing here! WF test seems great too with nice OOS results. So far I didn’t see something ‘strange’ in your code. I’m not used to trade or develop system with Hang Seng myself so please excuse my “limited knowledge” about it 🙂
What are exactly the difference between backtest and real trading? How did you simulate the HS50 spread in backtests?
Your ‘spread’ variable defined at line 18, may be the cause of differences, I remembered have read the same thing in the Pathfinder thread long time ago (I think it comes from there?), since you made calculation with it to define price levels and because this value may surely be different in real life, some dissimilarities should occur I think.
1 user thanked author for this post.
04/11/2017 at 10:05 PM #31794Yes the spread can be a problem (when using it in the code)
Say you have a spread of 12 (6 on each side) and you put a stoporder to buy at 10 000 (that would be 10 006)
and if price hit 10 001 the trade is open in real trading
but in backtest the price never hit the stoporder and no trade
1 user thanked author for this post.
04/11/2017 at 10:31 PM #31797Its late and i am tired so i try again
If the spread is 12 (6+6) and you want to put a stoporder to sell if price hit 10 000 minus spread (9 994 in the code)
then when the price hit 10 000 in real trading the trade is executed
but in backtest price have to hit 9 994
the problem is if price turns and never reach 9 994 then you have a difference real versus BT
1 user thanked author for this post.
04/12/2017 at 12:05 AM #31804Hi Nicolas
Thanks for your comment, I start PRT and found this nice website on Sep 2016, although spend many hours on it, still not well equipped to create some new idea.
Back to this system, I use 6 spread for backtest (pic attached).
About line 16, my thinking is let the SL don’t affect by the IG spread, but your advise may be right. I already take out this [spread] and put in Live trade again to test the different between backtest result.
04/12/2017 at 12:12 AM #3180704/12/2017 at 12:27 AM #31808Hi Nicolas and Eric
I check again live and backtest record, most big different came from exit which close to 6.
Although entry price got little bit different, but it can accept.
Really hope all mistake and error is come from me, not PRT. 🙏🙏
04/12/2017 at 7:15 AM #3181504/12/2017 at 11:22 PM #31899Hi!
I tested your strat, but i cant get the same results. What timezone do you use? What spread do you use in backtests? When i use CET time with original code and without spread i get a result simular to yours but not so good (see picture).
About the spread i the code it should just be a number called spread to calculate the sl. So i dont think thats the diffrense.
Whats the diffrence for you between live/demo and backtests?
Regards
Henrik
04/12/2017 at 11:36 PM #31902Hi Nicolas
I will test again and make a new comparison.
Hi Henrik
Thanks for your test, Time zone is UTC+8:00 andI use 6 spread for backtest (pic attached at post #31804).
Different between live and backtest pic attached at post #31808.
04/13/2017 at 12:35 AM #31903Hi Bin and Nicolas?!
Thanks! I looked pic attached at post #31808. and i think its mostly slippage. But look att the time where the orders are done. I did the same with my hs Pathfinder, a couple of sec fine for me but hours? Look at order on mars 21 and 16…..
Regards
Henrik
04/13/2017 at 1:51 AM #3190604/13/2017 at 12:39 PM #31935I agree Henrik use of term ‘spread’ in code is misleading because it bears no relation to spread applied by the dealer (PRT does not link to dealer spread)?
Whatever value is put against spread it is just another variable value, so maybe we should not use the term ‘spread’ in code then we stop confusing our brains and others / newbies?
Or am I wrong in my assertions / conclusions?
GraHal
1 user thanked author for this post.
-
AuthorPosts