GoldMiner

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #120331 quote
    Francesco
    Participant
    Veteran

    Noticed that there are no systems on Gold, so i tryed to develop one by myself.
    Here’s what i got, simple and effective

    Based on a simple moving average and a Breakeven function, with a limit to the operative time.

    Works on 4H.

    Paul, nonetheless and Nicolas thanked this post
    GoldMiner1.jpg GoldMiner1.jpg GoldMiner2.jpg GoldMiner2.jpg GOLD4HL.itf
    #120336 quote
    robertogozzi
    Moderator
    Master

    You should also post the whole code so that some interested may take a look at it without having to import it.

    Thank you. 🙂

    #120337 quote
    Francesco
    Participant
    Veteran

    Usually didn’t seen anyone doing that, but here it is 😉

    defparam cumulateorders = false
    
    // Long
    If average[20] CROSSES OVER average[55] THEN
    BUY 0.2 CONTRACTS AT MARKET
    ENDIF
    
    // Stop and target
    SET STOP pLOSS 0
    SET TARGET pPROFIT 25
    
    IF OnMarket AND (BarIndex - TradeIndex) >=93 THEN
    SELL      AT MARKET
    EXITSHORT AT MARKET
    ENDIF
    
    StartBreakeven = 0 // How much pips/points in gain to activate the Breakeven function?
    PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)
    
    // Reset the BreakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    BreakevenLevel=0
    ENDIF
    
    // Test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    
    // Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    SELL AT BreakevenLevel STOP
    ENDIF
    
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    
    //Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    EXITSHORT AT BreakevenLevel STOP
    ENDIF
    
    robertogozzi thanked this post
    #120339 quote
    robertogozzi
    Moderator
    Master

    You may have noticed code is usually not posted on large topics because people already know know what’s it all about and posting code everytime would make the topic difficult to read, but the first time it’s better to let the reader decide whether it is worthwhile or not (for him) importing it.

    Thank you.

    Francesco and jebus89 thanked this post
    #120342 quote
    Francesco
    Participant
    Veteran

    I was talking about first posts of new topics that i’ve seen recently, but doesn’t matter, it was what it was 🙂
    It’s surely more smart put the entire code in the first post for the reasons you listed.

    #120343 quote
    Vonasi
    Moderator
    Master

    I always like to see the code in the first post as I don’t always have my platform open 24/7 and so seeing how the strategy is coded is a lot of hassle of opening the platform and importing the code and I am generally to busy to bother doing that. If the code is in the first post however then I am able to immediately check it out and see if it is of interest or if I have anything to comment that might assist.

    #120360 quote
    nonetheless
    Participant
    Master

    Small alteration to your exit conditions:

    IF OnMarket AND (BarIndex – TradeIndex) >=93 and close>positionprice THEN …

     

    Makes a huge difference on 100k — gain/loss ratio of 370? worst trade -$4? seriously?

    Probably worth re-optimizing the bar number.

    #120372 quote
    Vonasi
    Moderator
    Master

    Makes a huge difference on 100k — gain/loss ratio of 370? worst trade -$4? seriously?

    Yes but one day you will open a trade at the top of the market and then the market will take a dive and you will go into massive account killing drawdown! Just because it does not happen in your backtest does not mean it can’t happen. Perhaps a robustness test would show this as perhaps the big DD trades are just not happening because of the start date and time meaning that you just so happened to be on the market and so missed those bad trades.

    #120386 quote
    nonetheless
    Participant
    Master

    Yes, the tone of voice was meant to imply that this may well be too good to be troo and needs more testing … it’s effectively only closing if in profit. But may be worth considering …

    #120394 quote
    Paul
    Participant
    Master

    added re-entry to see what it does, kind of a robustness-test

    defparam cumulateorders = false
    
    once reentry              =1 // close & re-entry on signal in same direction
    
    condbuy=average[20] CROSSES OVER average[55]
    
    if condbuy then
    signal=1
    else
    signal=0
    endif
    
    graph signal
    
    ctime=1
    
    // Long
    if ctime then
    
    If condbuy THEN
    
    if not onmarket then
    buy 1 contract at market
    endif
    
    if reentry then
    if longonmarket then
    sell at market
    endif
    endif
    endif
    
    if reentry then
    if condbuy[1] then
    if longonmarket[1] then
    buy 1 contract at market
    endif
    endif
    endif
    
    endif
    
    
    // Stop and target
    SET STOP pLOSS 0
    SET TARGET pPROFIT 25
    
    IF OnMarket AND close>positionprice and (BarIndex - TradeIndex) >=1 THEN
    SELL      AT MARKET
    ENDIF
    
    StartBreakeven = 0 // How much pips/points in gain to activate the Breakeven function?
    PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)
    
    // Reset the BreakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    BreakevenLevel=0
    ENDIF
    
    // Test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    
    // Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    SELL AT BreakevenLevel STOP
    ENDIF
    
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    
    //Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    EXITSHORT AT BreakevenLevel STOP
    ENDIF

    the breakeven though should be the other way around with it’s value’s

    when reaching a gain, then move breakevenlevel to 0, however it’s a nice equitycurve this way.

    Screenshot-2020-02-25-at-10.12.24.jpg Screenshot-2020-02-25-at-10.12.24.jpg Screenshot-2020-02-25-at-10.12.51.jpg Screenshot-2020-02-25-at-10.12.51.jpg
    #120400 quote
    Vonasi
    Moderator
    Master

    Probably worth re-optimizing the bar number.

    This is a terrible idea. Optimising on any time based idea is always going to be a great way to curve fit. As soon as I see numbers like 93 it instantly gets me worried that it is totally curve fitted.

    #120415 quote
    nonetheless
    Participant
    Master

    As soon as I see numbers like 93 it instantly gets me worried that it is totally curve fitted.

    But surely there must always be some optimal number, no? where optimal does not necessarily mean highest profit, could be lowest drawdown or %win or whatever helps you sleep at night.

    I don’t think there’s a good ‘theoretical’ reason for it not to be 93 or 71 or 57, esp in a 10 year backtest with WF and all the rest. Or is there?

    #120419 quote
    fifi743
    Participant
    Master
    defparam cumulateorders = false
    
    once reentry              =0// close & re-entry on signal in same direction
    
    condbuy=average[20] CROSSES OVER average[55] and (average[55]-average[55](close[1]))/pointsize> 0.1
    
    if condbuy then
    signal=1
    else
    signal=0
    endif
    
    graph signal
    
    ctime=1
    
    // Long
    if ctime then
    
    If condbuy THEN
    
    if not onmarket then
    buy 1 contract at market
    endif
    
    if reentry then
    if longonmarket then
    sell at market
    endif
    endif
    endif
    
    if reentry then
    if condbuy[1] then
    if longonmarket[1] then
    buy 1 contract at market
    endif
    endif
    endif
    
    endif
    
    
    // Stop and target
    SET STOP pLOSS 0
    SET TARGET pPROFIT 25
    
    IF OnMarket AND close>positionprice and (BarIndex - TradeIndex) >=1 THEN
    SELL      AT MARKET
    ENDIF
    
    StartBreakeven =0// How much pips/points in gain to activate the Breakeven function?
    PointsToKeep = 20 // How much pips/points to keep in profit above of below our entry price when the Breakeven is activated (beware of spread)
    
    // Reset the BreakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    BreakevenLevel=0
    ENDIF
    
    // Test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    
    // Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    SELL AT BreakevenLevel STOP
    ENDIF
    
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    //Calculate the BreakevenLevel
    BreakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    
    //Place the new stop orders on market at BreakevenLevel
    IF BreakevenLevel>0 THEN
    EXITSHORT AT BreakevenLevel STOP
    ENDIF
    

     

    Hello,
    Or add a filter

    Paul thanked this post
    GOLD4HL-1.itf Capture-d’écran-639.png Capture-d’écran-639.png
    #120443 quote
    Francesco
    Participant
    Veteran

    Robustness test results, nothing to do here 🙁

    Thanks to @paul for the excel file

    1-4.jpg 1-4.jpg 2-3.jpg 2-3.jpg 3-2.jpg 3-2.jpg
    #120469 quote
    Vonasi
    Moderator
    Master

    But surely there must always be some optimal number, no?

    Yes – but that optimal number is your curve fit. You have looked at history and said ‘that number of bars before exiting has worked the best in the past’ but that does not mean that it will work tomorrow or ever be the best number to use ever again. Now if you had say a range of numbers from 83 to 103 that all worked pretty similarly and all returned nice equity curves then picking 93 slap bang in the middle of that range might put you in with a fighting chance that it will continue to work even if 93 was not the best result or best equity curve.

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

GoldMiner


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 15 replies,
has 6 voices, and was last updated by Francesco
5 years, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/24/2020
Status: Active
Attachments: 11 files
Logo Logo
Loading...