Trading system template

Viewing 9 posts - 16 through 24 (of 24 total)
  • Author
    Posts
  • #186632 quote
    Kev Monaghan
    Participant
    Junior

    I started going through the system using your approach and right away found an outlier which would have eventually resulted in catastrophic loss or atleast many full hard stops taken out, the cause was my exit 2 was badly coded, I can see this is going to be a really helpful systematic approach to building my systems over time.

    #186640 quote
    deletedaccount051022
    Participant
    New

    Hi Kev Monaghan,  Great article, some really interesting ideas which intrigue and encourage further deliberation and testing.  Thank you for sharing, much appreciated.

    #191511 quote
    Kev Monaghan
    Participant
    Junior

    I am curious how do you feel about automating on 1 min time frame?

    Well, I could be about the only one in this community using a 1 second TimeFrame, but which is Forex. Personally I wouldn’t even be able to use longer timeframes, just because I wouldn’t be able to find the entries (with Forex), which I now find by technical means. Otherwise, and as I told before, I try to work quite exactly the same as you, but as told that doesn’t work out mostly (my code is fully stuffed with all such attempts).

    Otherwise, the advantage I seem to have is the fact (?) that the Strategies I have are winning, so all it requires is adding new ideas and see whether they work out for the better. This is the most convenient …

    And, without much exception you will find everybody in here having difficulties with the shorter timeframes; it was a discussion only a few weeks back.
    again) is that the peak you see on the 14th is actually traded off with more gain after it. And yes, it will be hard to believe that such things can be done, but this is how things work out when one sort of thinks like you do. The mechanism is always the attempt to diminish the subsequent losses (and it will be easy to understand how they will create the dips). That mechanism is just a workable one (I mean, one can deal with that) – as long as it does not go by optimisation. An easy to understand (and known) example is to skip a trade (coding such a thing may not be for everyone). Two losses after all ? then apply something else again.

    _________

    Edit: reformatted by moderation, please use the ” icon in toolbar to unquote text during your 5mn edit window when it has been misplaced inside a quote, thanks

     

    Hi Peter, I started working on trying to code a london reversal/london momentum system for NQ

    At the moment it is drawing down a bit to much so I am looking to get in lower with a 2nd entry and cut the bad entries better, I have been working on a price action signal/Indicator to use later based on Al brooks price action, but then again computer don’t care about drawdown,

    I have set max risk as a stop loss for 35% of equity but it is only hard stop.

    I also want to let the winners run a bit longer when they have potential or use the original main entry to trigger other sub systems.

    I am trying to trade based on a signal I see often on London open on NQ where the market ussually initiates a sustained momentum move.

    I can only backtest 100k candles, this is my latest base version, I have another original base version that gets good results on forex pairs that are in bulltrend but I forgot to check if this version is the same.

    The tf indicator was my first attempt at coding it is not doing anything but it is just the rsi.

    I started from 15min signal and after testing for positive results I dropped down to 3min charts to get more specific with entries and exits

    My goal as I said is to work with this signal in as many ways as possible, this is just a rough attempt at isolating a usable pattern.

    3min charts NQ or MNQ I used 6/22ALL,  starting capital 10k.

    I will probably try to make it wait to buy a flush when I am finished my price action indicator.

    LONDON-REVERSALV2-3m-TEST.itf
    #191545 quote
    PeterSt
    Participant
    Master

    Good morning there, Kev. I assumed a 3 minute chart, because this is what you mention in between the lines. Notice the difference (for result) with a 1 minute chart, despite the TimeFrame in the code remains the same (3 minute).
    Either way it is touch to see through what it should do, although we have your description. IMHO it is not working out really, at least not with not all technically working out, as how I see it.

    In the Editor window you should engage Tick by Tick mode (checkbox in the right pane of the main Editor screen).

    In the same window you set the spread to be 0.5. I think it should be 2 (though 1 will often do as well).

    The trading times in your code are ambiguous for me because I don’t know what time zone you exactly set. It occurs to me that for me they need to be one hour earlier (Amsterdam time instead of London time). Thus, start to be active at 30 minutes before opening of the USA stock market, deactivate at 15 minutes into it. Again, I must just guess this.

    Your midnight deactivation (the means to do it) is a bit beyond me – but this can be because I can’t know your thoughts. Anyway, it that would be my time 00:00. All combines with it not working anyway because trades are taken throughout. This is caused by this :

    //RESET CONDITIONS TO 0 AT END OF SESSION
    //IF TIME CROSSES OVER 230000 THEN
    //IF TIME CROSSES OVER 240000 THEN   // 10-04-2022,PS. But this does not work out to what's intended.
    IF TIME >= 0 THEN                    // 10-04-2022,PS. This does.
      WATCHING = 0
    ENDIF

    … with next the question what your “end of the session” means. To me that would be 22:00 my time, or 21:00 London time for the stock market. For the Nasdaq it would be 23:00 my time, 22:00 London.
    You have another of such “cross over” in there, which also requires changing like you see above.

    Because of Daylight Savings (active now in the USA for 4 weeks (I did not count really)), things won’t work out at all, also not because over here we’re into that 2 weeks less. And because your whole strategy seems to be hooked up to the opening (which idea is fine), nothing will work out really.

    Be careful with the end of the trading, would that be 14:45 your time. I mean, that first 15 minutes is indeed totally crucial, but since your steps are 3 minutes, that may not turn out as you want. Thus, would you like to make 14:46 of that, it does not work out with the 3 minute chart (it’s either 14:45 or 14:48 in that case).

    I only see just now that all the trades last one bar only. So this seems wrong to me in the first place. I hope that is not my fault.

    All ‘n all in the results I see a kind of random trades and this can’t be the intention. Below you see it for the 1 minute chart 90K bars, hence the past 3  months.


    I hope this is the kind of response you were asking for, as I did not see questions really. But it should get you going better ? I hope so !

    image_2022-04-11_035353.png image_2022-04-11_035353.png image_2022-04-11_035415.png image_2022-04-11_035415.png
    #191548 quote
    Kev Monaghan
    Participant
    Junior


    I hope this is the kind of response you were asking for, as I did not see questions really. But it should get you going better ? I hope so !”

     

     

    sorry peter my charts are set to +10 GMT Brisbane, Australia; the strategy is coded to that time.

    it is supposed to start ‘watching’ for a 15min signal that has a 60% probability at 1700 +10GMT; the London stock exchange open onwards until USA premarket.

    It appears I accidently started the strategy earlier however, 1600 is the time I start watching for algorithms to move the market prior to london open.

    as for the entries, they are not currently how I want them but i am working on an automated system for this and trade management as i would do manually.

    I have stepped down to 3min to try and get the most out of the time window but i will apply some changes as you suggest.

    at the moment some trades drawdown 100% of return so i am looking to fix this but here are the results from my time zone

    attached are my results and equity curve of 2x base versions.

    I will look over you comments and change some code; as for below; this is how I am keeping my original signal for recycling more setups, however right now I only have the one entry later i will initiate intraday trend trades etc from this signal to run winners further. I didn’t have many questions this time I just figured you would have good opinions as always, thankyou.

    //WATCHING THE ORIGINAL SIGNAL FOR MULTIPLE SETUPS
    ONCE WATCHING=0
    IF TIME > 160000 AND TIME <164500 AND CLOSE CROSSES OVER HIGH[1] THEN// AND TF<50 THEN //MAKES STRATEGY WIN 100%
    WATCHING=1
    ENDIF
    Detailed-report-ProBacktest-LONDON-REVERSALV2-3m-TEST-Mini-NASDAQ100-Full0622.png Detailed-report-ProBacktest-LONDON-REVERSALV2-3m-TEST-Mini-NASDAQ100-Full0622.png NQXXXX-3-minutes.png NQXXXX-3-minutes.png
    #191576 quote
    PeterSt
    Participant
    Master

    I just figured you would have good opinions

    All right Kev.
    Because there’s no way I can mimic your results, I figured that you’re doing this on PRT-IB (not PRT-IG). I mean, the ticker sure looks like that.
    So my next good opinion could be : No AutoTrading with PRT-IB so far …

    🙁
    ?

    PS: What is actually the investment you think you are doing ? it is not $5000 … It should be 284K, assumed PRT-IB indeed (no fractions on the contract quantity possible that I know of).
    There are so many things not working out, that it looks like you posted another code. The changed times help, but it is still not clear to me how *I* need to set them and Daylight Savings-changes are still in order for the period of back testing. Not that I per se want to get this going, but is is too much out of here to see such differences.

    #191577 quote
    Kev Monaghan
    Participant
    Junior

    I just figured you would have good opinions

    All right Kev.

    Because there’s no way I can mimic your results, I figured that you’re doing this on PRT-IB (not PRT-IG). I mean, the ticker sure looks like that.

    So my next good opinion could be : No AutoTrading with PRT-IB so far …

    🙁

    ?

    PS: What is actually the investment you think you are doing ? it is not $5000 … It should be 284K, assumed PRT-IB indeed (no fractions on the contract quantity possible that I know of).

    There are so many things not working out, that it looks like you posted another code. The changed times help, but it is still not clear to me how *I* need to set them and Daylight Savings-changes are still in order for the period of back testing. Not that I per se want to get this going, but is is too much out of here to see such differences.”

     

    Yes this is for IB, I was not aware they do not allow Auto trading, I normally use IG CFDs, which I haven’t tested this on yet.

    I am also working on learning C# because I am a bit limited by brokers as an Australian so I can not get the intraday margins on PRT at the moment but I have funding on another platform so if I can get things working here I can convert code to C#

    my backtest starts at 9th feb 2022, I can not test back further on 3 min charts also as you said daylight savings has moved time zones recently so if you test 1 million candles this will be a problem especially if my system is not good :).

    below is the simplified version of my code, the otehr version is not fully utilised yet, much of it is for later stages.

    Inprofit = Close[1] > Positionprice+(RANGE[tradeindex[1]]*0.5)
    
    // Conditions to enter long positions
    
    ST = Supertrend[1.5,100]
    ATR = AverageTrueRange[6](close)
    EMA8 = ExponentialAverage[8](close)
    
    
    // STARTS WATCHING FOR SETUPS FROM HIGH PROBABILITY TRIGGER
    ONCE WATCHING = 0
    IF TIME > 160000 AND TIME <164500 AND CLOSE CROSSES OVER HIGH[1] THEN
    WATCHING = 1
    ENDIF
    
    // MAIN ENTRY CONDITION
    E1 = WATCHING = 1 AND CLOSE CROSSES OVER HIGH[2] AND TIME<164500
    
    IF NOT LONGONMARKET AND E1  THEN
    BUY 1 CONTRACTS ROUNDEDUP AT EMA8+0.25 LIMIT
    ENDIF
    
    //MAIN ENRTY EXITS
    EX1 = TIME CROSSES OVER 003000 AND NOT INPROFIT
    EX2 = INPROFIT AND RANGE CROSSES OVER ATR*1.5 AND CLOSE > ST
    
    IF LONGONMARKET AND EX1 OR EX2 THEN
    SELL AT MARKET
    ENDIF
    
    //HARD STOP LOSS
    SET STOP $LOSS (5000+STRATEGYPROFIT)*0.35
    
    //RESET CONDITIONS TO 0 AT END OF SESSION
    IF TIME CROSSES OVER 230000 THEN
    WATCHING = 0
    ENDIF
    

    here is the original test that i gave you; i will upload both from version I just tested.

    DEFPARAM CUMULATEORDERS = TRUE
    TIMEFRAME(3MN)
    //THIS STRATEGY REQUIRES A 'guaranteed' STOP LOSS
    //Requires atleast 5k starting capital
    STARTINGCAPITAL = 5000 //TESTED CAPITAL: USE 2x or 3x to start strategy to account for outliers
    RISKSCALE = 5000// $ AMOUNT OF EQUITY REQUIRED TO TRADE 1 CONTRACT
    POSITIONSIZING = (STARTINGCAPITAL+STRATEGYPROFIT)/RISKSCALE //NUMBER OF CONTRACTS TRADED BASED ON EQUITY AND RISK
    EXPONETIALRISKLIMIT = 0.5// PERCENT OF EQUITY TO RISK PER ENTRY: STOP LOSS = (LOSSLIMIT/RISKADJUST)*EXPONETIALRISKLIMIT = (TOTALEQUITY/TRADESIZE)*EXPONENTIALRISKLIMT EG (2000/2)*0.025 SETS STOPLOSS AT 25 POINTS OR $1000
    R = 2 //RISK ADJUSTMENT FOR MAX CONTRACT VALUE BEFORE AUTO SCALING DOWN RISK INITIATES
    //SELF SCALING CAPITAL PROTECTION / ADJUST TO SCALE DOWN RISK AS PROFIT ACCUMULATE
    
    RISKADJUST = POSITIONSIZING
    IF POSITIONSIZING => R THEN
    RISKADJUST = POSITIONSIZING*0.5
    IF POSITIONSIZING => R*5 THEN
    RISKADJUST = POSITIONSIZING*0.25
    IF POSITIONSIZING => R*10 THEN
    RISKADJUST = POSITIONSIZING*0.1
    IF POSITIONSIZING => R*20 THEN
    RISKADJUST = POSITIONSIZING*0.05
    IF POSITIONSIZING => R*50 THEN
    RISKADJUST = POSITIONSIZING*0.025
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    //SYSTEM EQUITY CHECK // ADJUST FOR TOTAL AMOUNT OF EQUITY TO RISK ON THIS SYSTEM
    LOSSLIMIT = STRATEGYPROFIT + STARTINGCAPITAL
    IF LOSSLIMIT>0 THEN
    SYSTEMPOSITIVE=1
    ELSIF LOSSLIMIT=<0 THEN
    SYSTEMPOSITIVE=0
    ENDIF
    PROFITABLESTRATEGY = SYSTEMPOSITIVE=>1 // CONDITION TO ONLY TRADE WHEN SYSTEM HAS NEUTRAL TO POSITIVE EQUITY
    
    
    
    FULLSIZE = COUNTOFPOSITION => RISKADJUST[TRADEINDEX(1)]// USED TO PREVENT SCALING DOWN TO MUCH TO EARLY //NOT USED CURRENTLY
    ADDSIZE = RISKADJUST - COUNTOFPOSITION //SIZE USED TO CALCULATE ADDS IN LINE WITH RISK RATIO
    COP50 = Countofposition*0.5
    
    Inprofit = Close[1] > Positionprice+(RANGE[tradeindex[1]]*0.5)
    
    // Conditions to enter long positions
    TIMEFRAME(3MN)
    ST = Supertrend[1.5,100]
    ATR = AverageTrueRange[6](close)
    tf = CALL "trendf"
    EMA8 = ExponentialAverage[8](close)
    EMA13 = ExponentialAverage[13](close)
    
    //WATCHING THE ORIGINAL SIGNAL FOR MULTIPLE SETUPS
    ONCE WATCHING=0
    IF TIME > 160000 AND TIME <164500 AND CLOSE CROSSES OVER HIGH[1] THEN// AND TF<50 THEN //MAKES STRATEGY WIN 100%
    WATCHING=1
    ENDIF
    
    // MAIN SETUP
    E1 = WATCHING=1 AND CLOSE CROSSES OVER HIGH[2] AND TIME<164500
    
    
    IF NOT LONGONMARKET AND E1 AND NOT FULLSIZE THEN
    BUY RISKADJUST CONTRACTS ROUNDEDUP AT EMA8+0.25 LIMIT
    ENDIF
    
    
    
    //HARD STOP FAILSAFE
    SET STOP $LOSS (STARTINGCAPITAL+STRATEGYPROFIT)*EXPONETIALRISKLIMIT
    
    //RESET CONDITIONS AT END OF SESSION
    IF TIME CROSSES OVER 230000 THEN
    WATCHING=0
    ENDIF
    

    I am not sure what else could be going on, I will probably try to test this on IG markets cfd during the week as I have a very high leverage account with them but I haven’t used it in some time, I don’t plan on running live for a long time, at this stage algorithmic trading is just for fun and my manual trading is more serious.

    LONDON-REVERSALV2-3m-SIMPLE.itf LONDON-REVERSALV2-3m-TEST-1.itf
    #191608 quote
    Kev Monaghan
    Participant
    Junior

    I will probably turn the entry into a box breakout of the post asia pre europe range; at the moment it is just an interesting statistic that you can get a very high win rate with a reasonable drawdown 1 to 1 drawdown but obviously needing a lot of work to make a viable system an eliminate drawdown where possible.

    #191613 quote
    Kev Monaghan
    Participant
    Junior

    My box idea worked, I wont share exact method so as to protect my liquidity but if anyone is interested I used a time box.

    LONDON-REVERSAL.png LONDON-REVERSAL.png LONDON-REVERSAL-EQUITY.png LONDON-REVERSAL-EQUITY.png
Viewing 9 posts - 16 through 24 (of 24 total)
  • You must be logged in to reply to this topic.

Trading system template


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 23 replies,
has 5 voices, and was last updated by Kev Monaghan
3 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/24/2022
Status: Active
Attachments: 21 files
Logo Logo
Loading...