Silver gun Strategy NQ and ES 4 hours

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #240069 quote
    Aragorna
    Participant
    Junior
    //NQ  10-20-2.5-9-25-40-180-22
    //ES  10-8-1.5-7-25-40-38-20
    DEFPARAM CumulateOrders = false
    
    Positionsize=1
    C1= Close>high[1]
    C2=Low<Low[1]
    C3=High-Low>=K2
    C5=(open-low)>=0.10*(high-low)
    If not ONMARKET and C1 and C2 and C3 and c4 and C5 and SS then
    Buy positionsize contract at market
    
    EndIf
    C4 =RSI[K7](close) > K6
    AGBARLong = AverageTrueRange[14](close)
    SS=AGBARLong =< NN
    
    //calcola differenza di prezzo
    StopLoss = abs(close - low[1])+K4
    
    SET STOP LOSS StopLoss*10           //setta lo SL in differenza di prezzo
    SET TARGET PROFIT StopLoss*K3
    
    //trailing stop function
    trailingstart = K5// RR 20trailing will start @trailinstart points profit-50
    trailingstep = 10// 5trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT LONGONMARKET  THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    

    Hello to everyone,

    It’s a long time I don’t see someone sharing a strategy, maybe everyone is jealous of their own work. By the way I want to share this simple strategy on 4 hours timeframe, I use futures on IB; parameters are for Nasdaq, but they can be adapted for ES (parameters are on top of strategy).

    actually I’m using other strategies but it looks promising.

    please share your opinion how we can improve it, with some other filters. Filters are something that  I have more difficulties to find and tune.

    Alessio

    GraHal, robertogozzi, KumoNoJuzza and JS thanked this post
    #240070 quote
    Aragorna
    Participant
    Junior

    here below the file

    Silver-gun-4H-NQ.itf
    #240076 quote
    Iván González
    Moderator
    Master

    Thank you very much for your contribution. I hope that people will comment and give you feedback. I will analyze it myself. Perhaps something can be done with the capital management part (number of contracts) based on results.

    #240082 quote
    Aragorna
    Participant
    Junior

    thank you Ivan. Stop loss is dinamic, it works the same removing *10 but you have half gain. with *10 you have 27K drawdown, without it just 10K.

    #240148 quote
    Anjuna Marine
    Participant
    New

    Hey Aragorna, thanks for sharing this. I’ve had a play and tested the system with out-of-sample data and adjusted the optimisation for more practical results.

    With a starting margin of £10,000 and using all of it for position sizing, I tested the original code on Jan 2018 to Nov 2024. This setup generated £72k in profit, with a max drawdown of -£20k. Every year since 2009 was profitable except for 2021, which saw a minor loss. It’s promising in back-testing, though I haven’t accounted for overnight funding costs yet.

    To dig deeper, I checked performance from 2011 to 2017 (inclusive), and it incurred a £23.5k loss with spreads factored in, but excluding any overnight funding. This suggests possible overfitting. I noticed you left variable optimisations in the ITF file, so I’m re-optimising it on 2011-2017 data.

    30 minutes later…

    After re-optimising, the in-sample back test (2011-2017) shows a profit of £24k with a -£15k max drawdown. Gains are somewhat uneven, with £18k concentrated in 2009, and other years near break-even. Using these new optimised parameters, the system’s out-of-sample performance (2018 to date) gives us £22.5k in gains and a max drawdown of -£8.6k. The system maintained a relatively stable equity curve throughout the 2022 downturn, which can be a good sign for a long-only strategy.

    While I haven’t conducted WF testing, or Monte Carlo simulations, these results suggest it’s not quite ready to trade solo. However, it could be valuable as part of a portfolio of uncorrelated systems, taking advantage of big bull runs. Would just have to calculate those overnight funding costs and see how that affects.

    Hope this analysis sheds some light!

    Be interesting to know exactly what the system is doing and your thoughts behind it. I tested and optimized without reading too much into the code.

    GraHal thanked this post
    #240154 quote
    Aragorna
    Participant
    Junior

    Hi anjuna,

    thanks for testing.Just to be clear, are  You using IB or IG ?because results can be different on CFd or on Mini Nasdaq or Mini ES.  in attachment results I have, including also walk forwards (1 test).

    Equity-Silver-gun-4-hours-NQ.jpg Equity-Silver-gun-4-hours-NQ.jpg Equity-Silver-gun-4-hours-NQ-Results.jpg Equity-Silver-gun-4-hours-NQ-Results.jpg Walk-forward-NQ-Silver-Gun.jpg Walk-forward-NQ-Silver-Gun.jpg Silver-Gun-4H-ES-EquityResults.jpg Silver-Gun-4H-ES-EquityResults.jpg
    #240159 quote
    Aragorna
    Participant
    Junior

    and this missing file attached( Walk forward for ES) . parameters seem more than should be but in the end they are useful to tune for the instrument to be traded. K1 is not even used in strategy, I use it only for testing walk forward (if I don’t let a parameter on optimisation, I cannot use walk forward.

    K2 is adapted to the typical lenght of push candles that are different from NQ to ES.  then there are a couple of fitlers , RSI and ATr, for filter out some trades. It’s a strategy I wrote in 15  minutes, could be better than this.

    The idea behind this strategy is that usually before a bullish run, there is a strong push that is caught by these conditions. But I’m not a big fun of 4 hours strategy, I prefer using 30 minutes and 1 hour in general.

    Silver-Gun-4H-ES-Walk-Forward.jpg Silver-Gun-4H-ES-Walk-Forward.jpg
    #240161 quote
    Aragorna
    Participant
    Junior

    ffor my little experience, I’ve seen a transformation of ES and NQ futures, like others futures, from 2020. I prefer to optimise and run strategies that work better in last four years and a little less better years before 2020 and this is confirmed by some strategies that I’m running from June that have behaved much better than I expected. In attachment I have the equities of 2 strategies I’m running Out of Samples from june on microNasdaq and MicroES, that (fingers crossed) I hope will behave in the future in a good way. I’d like to share here some ideas on how you create strategies and adapt on actual markets.

    Alessio

    Equities-of-2-strategies-MNQ-and-MES-from-June.jpg Equities-of-2-strategies-MNQ-and-MES-from-June.jpg
    #240163 quote
    Aragorna
    Participant
    Junior

    I don’t use spread for backtesting but commissions.  that could be also the difference, but not too much thinking strategy work in 4 hours.

    #240174 quote
    Anjuna Marine
    Participant
    New

    I’m using IG on a UK Spread Betting account. The markets on this type of account are called US Tech 100 (DFB) and US 500 (DFB).

    Thanks for the additional information and screenshots of your results. It’s interesting, I’ll take another look, this time at your ES version. I’ll use the same sizing as you have used and try to replicate the results.

    I completely agree about placing less importance on older data. I guess I was trying to break the system or find its weakness and perhaps going back as far as 2009 was unfair to the system as it has less relevance. On the higher timeframes (daily) and when trading longer time horizons it can help to look back over 20 years, but for short term trades, recent data is going to be a better indication of how the markets are currently moving. I’ve found this to be particularly true about the NASDAQ and the DAX in recent years.

    I’ll feedback again once I’ve had a fresh look, hopefully within the next few days.

    #250812 quote
    Aragorna
    Participant
    Junior

    just for updates, strategies are doing well, in particular NQ.

    #250835 quote
    Anjuna Marine
    Participant
    New

    Thanks for the update. I revisited your strategy on NQ and re-optimised using 2011–2020 data. It still holds up well out of sample. How does my equity curve compare with yours?

    I’m using a dynamic trade size based on a fixed capital allocation rather than a flat 1-point size, so the equity curve, gains, and losses stay comparable even as NQ’s price rises.

    Silver-Gun-optimised-2011-2020-NQ-4h-with-OOS-equity-curve.png Silver-Gun-optimised-2011-2020-NQ-4h-with-OOS-equity-curve.png
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Silver gun Strategy NQ and ES 4 hours


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Aragorna @aragorna Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Anjuna Marine
5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/07/2024
Status: Active
Attachments: 8 files
Logo Logo
Loading...