Trend following strategy for Gold

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #52825 quote
    victormork
    Participant
    Veteran

    I started a trend following strategy for gold but I’ve run out of ideas so I thought I can just post it here so anyone who wants to can come with ideas on how to improve it.

    Main issues are:

    • Stop loss distance is massive!
    • I have not found a good way to close losing positions before the drawdown becomes too big which is visible on the equity curve buy negative spikes.
    //XAUDUSD(EUR1 Contract) - IG MARKET
    // TIME FRAME 1H
    // PROBACKTEST TICK by TICK - 100.000 bars
    // SPREAD 0.5 PIP
    
    DEFPARAM CumulateOrders = FALSE
    DEFPARAM Preloadbars = 200
    
    tradingtime            = (currenttime >= 030000 and currenttime <= 180000)
    
    CP1                     = 4
    CP2                     = 4
    
    shorttrend              = supertrend[4,10]
    longtrend               = supertrend[7,24]
    
    
    // INDICATORS
    
    ///FRACTAL INDICATOR
    if close[cp1] >= highest[2*cp1+1](close) then
    LH = 1
    else
    LH=0
    endif
    if close[cp2] <= lowest[2*cp2+1](close)  then
    LL= -1
    else
    LL=0
    endif
    
    if LH=1 then
    HIL = close[cp1]
    endif
    
    if LL  = -1 then
    LOL=close[cp2]
    endif
    
    // ENTRY CONDITIONS
    C1 = not longonmarket
    C1 = C1 and (close crosses over LOL)
    C1 = C1 and tradingtime
    C1 = C1 and close > longtrend
    
    // ENTRY CONDITIONS
    S1 = not shortonmarket
    S1 = S1 and (close crosses under HIL)
    S1 = S1 and tradingtime
    S1 = S1 and close < shorttrend
    
    //ENTRY LONG
    IF C1 THEN
    BUY 10 CONTRACT AT MARKET
    ENDIF
    
    // ENTRY SHORT
    IF S1 THEN
    SELLSHORT 10 CONTRACT AT MARKET
    ENDIF
    
    // Exit Long
    If longonmarket and close > HIL then
    sell at market
    endif
    
    // Exit Short
    If shortonmarket and close < LOL  then
    exitshort at market
    endif
    
    //trailing stop
    trailingstop = 4
     
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
     
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
     
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    // stoploss
    Set stop ploss 80
    
    Skärmavbild-2017-11-15-kl.-11.59.32.png Skärmavbild-2017-11-15-kl.-11.59.32.png
    #52827 quote
    StantonR
    Participant
    Senior

    Hi Victor

    I am busy playing with your strategy now as I have been looking for a good gold strategy.

    I have implemented a trailing stop and a donchian stop. I am busy running a walk forward now with a number of parameters will share results when done.

    victormork thanked this post
    #52834 quote
    victormork
    Participant
    Veteran

    Cool! If you are looking for strategies on gold you can also check out the one I posted in the library –> https://www.prorealcode.com/prorealtime-trading-strategies/internal-bar-strength-gold-xauusd-2-hours-timeframe/

    #52835 quote
    StantonR
    Participant
    Senior

    Thats the strategy I am optimizing. I find the draw down and max losses are still to high on that one.

    #52839 quote
    victormork
    Participant
    Veteran

    Oh alright. The one I posted here is different though.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Trend following strategy for Gold


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
victormork @victormork Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by victormork
8 years, 3 months ago.

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