Breakout system for Hong Kong HS50 Cash (HKD10 Mini)

Viewing 15 posts - 16 through 30 (of 35 total)
  • Author
    Posts
  • #31939 quote
    BC
    Participant
    Master

    Hi Grahal

    Sound right, all I can do now is compare live result again, but no deal on yesterday and today.

    #31949 quote
    GraHal
    Participant
    Master

    Your Strat is very good Bin!

    I tried 3 or 4 times to minus 7 hours from all your times (UTC +8) to get to my time (GMT +1 / UTC +1)  but I’m sure due to my ‘finger trouble’ I got big overall loss.

    So I changed my Platform to UTC +8 and now it works great, results attached.

    When I get the GMT+1 times correct, I’ll post the code on here so others can test and we can compare Trades.

    GraHal

    BC and Henrik thanked this post
    Bin.jpg Bin.jpg
    #31962 quote
    Eric
    Participant
    Master

    I dont know why this strategy perform different live versus backtest

    But generally speaking about this “spread” thing

    When dealing with IG CFD/SB you have a midprice (that price we see on the charts and if nothing has changed lately also used in backtesting)

    and then you have the spread we can call it bid and ask, if the spread are 12 points and the midprice is 1000 then the bid is 994 and ask 1006

    when trading live with stop and limit you can get filled on a stoporder even if the midprice not touch the stop and to get filled on the limitorder the midprice must be 6 points higher then the limit

    The problem is if the bid touch the stop and the midprice dont and  if midprice touch the limit but not the ask

    this problem is bigger with bigger spread  (and many trades with small win/loss), if trading dax with 0,5 on each side you probably get filled on every trade

     

    If i am wrong about this please enlighten me

    (when using markets order this is not a problem, only stops and limits)

    BC and GraHal thanked this post
    #31963 quote
    Eric
    Participant
    Master

    When thinking about it why not use one version in live and a version with spread added (in the code) in backtesting then the result would be similar?

    when dealing with large spread and stop/limit

    BC thanked this post
    #31965 quote
    BC
    Participant
    Master

    Hi Eric

    Yes, that’s what I think (Wish I am wrong instead of PRT bugs).

    I already start live (no spread built in, with little bit amend) 2 days ago, but no trade trigger due to market situtation.

    //Market: Hong Kong HS50 Cash (HKD10 Mini)
    //Time Zone: UTC+8:00
    //Time Frame: 15 mins
    //Please manual stop the system on Hong Kong public hoilday.
    //Remark: Offical HSI future night trade start from 2013-04-08, 17:00-23:00, amended on 2014-11-03, 17:15-23:45
    
    // code-parameter
    DEFPARAM FlatAfter = 234500  //234500
    
    // window high/low calculation
    ONCE StartTime = 90000//91500
    ONCE EndTime = 93000//100000
    
    // trading window
    ONCE BuyTime = EndTime
    ONCE SellTime = 234500  //234500
    
    //Money management
    ONCE PositionSize = 1
    ONCE Capital = 10000
    ONCE Risk = 5
    ONCE MaxD = 50 // Quit system if highest close account balance drop over xx%
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    
    //Check system account balance
    if equity<QuitLevel then
    quit
    endif
    recordhighest = MAX(recordhighest,equity)
    QuitLevel = recordhighest*((100-MaxD)/100)
    
    //MA Filter
    FMA=Average[80](close)
    SMA=Average[200](close)
    
    // calculate breakout box high/low and sl/tp
    IF Time >= StartTime AND Time <= EndTime THEN
    IF TIME = StartTime THEN
    DailyHigh = High
    DailyLow = Low
    ENDIF
    IF High > DailyHigh THEN
    DailyHigh = High
    ENDIF
    IF Low < DailyLow THEN
    DailyLow = Low
    ENDIF
    
    sl = min(120,(max(30,((DailyHigh - DailyLow)))))
    tp = sl*4
    
    PositionSize = min(10,(max(1,abs(round((maxrisk/sl)/PointValue)*pipsize))))
    
    TradeCounterLong = 0
    TradeCounterShort = 0
    ENDIF
    
    //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.
    //Long
    LOK1=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))
    
    //Short
    SOK1=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 management
    IF Time >= BuyTime AND Time <= SellTime THEN
    
    //Long Entry
    IF Not LONGONMARKET and (LOK1 or LOK2 or LOK3 or LOK5) and close>DailyHigh and FMA>SMA and TradeCounterLong=0 THEN
    BUY PositionSize CONTRACT AT MARKET
    TradeCounterLong = TradeCounterLong + 1
    ENDIF
    
    //Short Entry
    IF Not SHORTONMARKET and (SOK1 OR SOK2 OR SOK4 OR SOK5) and close<DailyLow and FMA<SMA AND TradeCounterShort=0 THEN
    SELLSHORT PositionSize CONTRACT AT MARKET
    TradeCounterShort = TradeCounterShort + 1
    ENDIF
    
    // trailing stop function
    ONCE trailingStepLong = 0.08// in %
    ONCE trailingStepShort = 0.08 // in %
    trailingStartLongInPoints = max(30,(TP/5))
    trailingStartShortInPoints = max(30,(TP/4))
    trailingStepLongInPoints = max(10,(tradeprice(1) * trailingStepLong / 100))
    trailingStepShortInPoints = max(10,(tradeprice(1) * trailingStepShort / 100))
    
    // reset the stoploss value
    IF NOT ONMARKET THEN
    newSL = 0
    ENDIF
    
    // manage long positions
    IF LONGONMARKET THEN
    // first move (breakeven)
    IF newSL = 0 AND close - tradeprice(1) >= trailingStartLongInPoints * pipsize THEN
    newSL = tradeprice(1) + trailingStepLongInPoints * pipsize
    ENDIF
    // next moves
    IF newSL > 0 AND close - newSL >= trailingStepLongInPoints * pipsize THEN
    newSL = newSL + trailingStepLongInPoints * pipsize
    ENDIF
    ENDIF
    
    // manage short positions
    IF SHORTONMARKET THEN
    // first move (breakeven)
    IF newSL = 0 AND tradeprice(1) - close >= trailingStartShortInPoints * pipsize THEN
    newSL = tradeprice(1) - trailingStepShortInPoints * pipsize
    ENDIF
    // next moves
    IF newSL > 0 AND newSL - close >= trailingStepShortInPoints * pipsize THEN
    newSL = newSL - trailingStepShortInPoints * pipsize
    ENDIF
    ENDIF
    
    // stop order to exit the positions
    IF newSL > 0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    // close positions
    IF Time = SellTime THEN
    IF LONGONMARKET THEN
    SELL AT MARKET
    ENDIF
    IF SHORTONMARKET AND Time = SellTime THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    
    // stops and targets
    SET STOP pLOSS sl
    SET TARGET pPROFIT tp
    
    ENDIF
    GraHal, Midlanddave, ALE and Nicolas thanked this post
    #32334 quote
    Henrik
    Participant
    Veteran

    Hi!

    @Grahal, Did you manage to translate it to CET? Ive tried a couple of times to but have the same problem.

    Do you know why @Nicolas?

    #32365 quote
    GraHal
    Participant
    Master

    @Henrik ah I thought it was me! No I’ve not done it again since, forgot sorry and been out over Easter holiday.

    I had 4 attempts to change all the times (to UTC+1) and was more deliberate and careful each successive time, I even used find & replace and none of my attempts worked / produced good results.

    Weird … only thing I can think of is that not all Bins times are UTC +8?

    What you reckon @Bin … is every time used in your code set to UTC + 8 please?

    Thanks
    GraHal

    #32372 quote
    BC
    Participant
    Master

    Hi Grahal

    Yes, all UTC+8:00

    #32373 quote
    Elsborgtrading
    Participant
    Veteran

    I tried also to change the code for +1GMT, even change all Asian market to +8GMT but nothing worked.

    cheers Kasper

    #32397 quote
    GraHal
    Participant
    Master

    Worked good for me if I changed my whole Platform time to UTC +8 (see my results here #31949).

    This is very odd, we need to find the reason?

    I know it sounds daft, but please Bin say what time it is where you are and post the time on a message here.  Whoever sees your post as soon as you post it then check what your clock is showing and post here?

    GraHal

    #32431 quote
    BC
    Participant
    Master

    Hi Grahal

    Yes, I think change whole platform time to UTC+8:00 before backtest or start live is the only choice. Just like Reiner Hang Seng PF, I try to many many setting to fit for UTC+8:00 but failed. Finally I change whole platform time to UTC+1:00 and then start the system. (May be the issue of summer and winter time? )

    #32450 quote
    Henrik
    Participant
    Veteran

    Hi Bin and Grahal!

    I need CET time for my other strategies, so i need to figure something out here.


    @BIN
    are you shore you have +8 setting on hs chart?

    I ran original code with CET times and got a simular result but not the same, See lower test on picture on erlier post.

    Regards

    Henrik

    #32462 quote
    BC
    Participant
    Master

    No luck, live and back test result still different on no [spread] version.

    Live exit on 19:00 but back test exit on 18:00.

    3-Left-Live-Right-Backtest.png 3-Left-Live-Right-Backtest.png 2-Left-Live-Right-Backtest.png 2-Left-Live-Right-Backtest.png 1-Left-Live-Right-Backtest.png 1-Left-Live-Right-Backtest.png
    #32471 quote
    GraHal
    Participant
    Master

    @Bin when next you post, please type on this Page the time that the clock on your computer is shwoing when you press Submit below.

    Thank You
    GraHal

    #32478 quote
    BC
    Participant
    Master

    Hi Grahal

    Screen cap attached.

    Time.png Time.png
Viewing 15 posts - 16 through 30 (of 35 total)
  • You must be logged in to reply to this topic.

Breakout system for Hong Kong HS50 Cash (HKD10 Mini)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BC @robin_chan Participant
Summary

This topic contains 34 replies,
has 6 voices, and was last updated by BC
8 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/11/2017
Status: Active
Attachments: 14 files
Logo Logo
Loading...