Script stops buying in high volume or sudden movements

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #107460 quote
    SIMONIS
    Participant
    Junior

     

    I backtested it (excl spread) and it had good results (8% gain during 2 sept – 13 sept), see attachment

    What did happen was that is created in backtesting many small orders which are not generated if you are in auto trading. So this is lowering the result if you test with spread.

    So i adjusted the stop loss (see code below)

    I just run it now in auto trading (demo environment) with good results so far (see attachment).

    Keep you posted after the opening to at 15:30 CET

    DEFPARAM CumulateOrders = FALSE
    
    // Russell 2000
    // Timeframe 1 min
    
    // INPUT
    
    STARTTIME = 000000
    
    ENDTIME = 220000
    
    EURO = 1.10989
    
    EXPOEURO = 7500
    
    PRO = 0.04
    LOS = 0.2
    
    // CALCULATIONS
    
    MAXLOSS = ((EXPOEURO / 100) * -5)
    
    EXPOSURE = (EXPOEURO * EURO)
    
    TRAIL = LOS * (EXPOSURE /100)
    
    NUMBEROFCONTRACTS = (EXPOSURE / Open ) * (1 / POINTVALUE)
    
    // CONDITIONS
    
    NOTTRADING = not onmarket
    WINDOW = currenttime >= starttime and currenttime <= endtime
    SAMEBAR = tradeindex = barindex
    OTHERBAR = tradeindex < barindex
    MOREPROFIT = strategyprofit >= strategyprofit[1]
    LESSPROFIT = strategyprofit < strategyprofit[1]
    NOPROFIT = strategyprofit = 0
    LASTLONG = longonmarket[1]
    LASTSHORT = shortonmarket[1]
    
    CURRENTshort = (Average[20](close) >= Average[50](close))
    CURRENTlong = (Average[20](close) < Average[50](close))
    
    FIRSTORDER = NOTTRADING and window and NOPROFIT
    
    CONTINUELONG = NOTTRADING and window and OTHERBAR and MOREPROFIT and LASTLONG
    SWITCHLONG = NOTTRADING and window and OTHERBAR and LESSPROFIT and LASTSHORT
    SWITCHSHORT = NOTTRADING and window and OTHERBAR and LESSPROFIT and LASTLONG
    CONTINUESHORT = NOTTRADING and window and OTHERBAR and MOREPROFIT and LASTSHORT
    
    CONTINUESAMEBAR = NOTTRADING and window and SAMEBAR
    
    CONTINUELONGINBAR = CONTINUESAMEBAR and CURRENTLONG
    CONTINUESHORTINBAR = CONTINUESAMEBAR and CURRENTSHORT
    
    if not firstorder and not continuelong and not switchlong and not switchshort and not continueshort and not continuelonginbar and not continueshortinbar then
    CONTINUELONG = NOTTRADING and window and OTHERBAR and CURRENTlong
    CONTINUESHORT = NOTTRADING and window and OTHERBAR and CURRENTshort
    endif
    
    
    if FIRSTORDER or CONTINUELONG or SWITCHLONG or CONTINUELONGINBAR then
    
    Buy NUMBEROFCONTRACTS CONTRACTS AT MARKET
    
    endif
    
    if SWITCHSHORT or CONTINUESHORT or CONTINUESHORTINBAR then
    
    SELLSHORT NUMBEROFCONTRACTS CONTRACTS AT MARKET
    
    endif
    
    if strategyprofit < MAXLOSS then
    QUIT
    endif
    
    // STOPS
    
    SET STOP $TRAILING TRAIL
    
    SET TARGET %PROFIT PRO
    
    //graph window
    //graph NOTTRADING
    //graph OTHERBAR
    //graph SAMEBAR
    //graph MOREPROFIT
    //graph LESSPROFIT
    //graph LASTLONG
    //graph LASTSHORT
    //graph FIRSTORDER
    //graph CONTINUELONG
    //graph SWITCHLONG
    //graph CONTINUELONGINBAR
    //graph SWITCHSHORT
    //graph CONTINUESHORT
    Screen-Shot-2019-09-13-at-2.46.41-PM.png Screen-Shot-2019-09-13-at-2.46.41-PM.png Screen-Shot-2019-09-13-at-2.45.39-PM.png Screen-Shot-2019-09-13-at-2.45.39-PM.png
    #107468 quote
    robertogozzi
    Moderator
    Master

    @SIMONIS, I would like to point out that using only UPPERCASE letters for variable names makes them less readable and a bit more difficult to understand and debug.

    Mixing UpperCase and LowerCase letters would be beneficial to readers. Thank you.

    #107491 quote
    SIMONIS
    Participant
    Junior

    Hi Robert,

    Sure, next time I will take notice of this.

    I am running the earlier mentioned script in demo since 13:00 CET and have very good results, see attachment (Russell 2000 timeframe 1 min)

    93% winning trades

    gain / loss ratio : 2.37

    Doing good in short and long positions.

    Take again for your help.

    Greetings Hubert

    Screen-Shot-2019-09-13-at-5.14.05-PM.png Screen-Shot-2019-09-13-at-5.14.05-PM.png
    #107579 quote
    GraHal
    Participant
    Master

    @SIMONIS I made a few minor changes and I got attached on 10 sec TF at spread = 2 (trades times are daytime only).

    Judging from the equity curve it needs some work doing on the sellshort and / or the exitshort?? See the red arrowheads for an example … the trade stayed short all through that rise in price.

    Sim.jpg Sim.jpg Sim-2.jpg Sim-2.jpg
    #107582 quote
    GraHal
    Participant
    Master

    Apologies if I screwed your code to get the results above?

    For what it’s worth … attached is the .itf I used to get above curve.

    Curve attached (using .itf attached) is even slightly better as I was using the capture above was with the Vonasi VRT Tester.

    Sim-3.jpg Sim-3.jpg SAM-4.jpg SAM-4.jpg SIM1.itf
    #107593 quote
    SIMONIS
    Participant
    Junior

    Hi GraHal,

    Thanks for your update.

    From the updated script I can’t see the values your are using for A83 / A84 ? Can you clarify ?

    Any reason for not using Trailing stop ? Performs much better.

    Thanks

    #107616 quote
    GraHal
    Participant
    Master

    I can’t see the values your are using for A83 / A84

    Aren’t values for A83 and A84 shown in the optimiser?

    I wanted to get a feel for the levels of gain and loss that this System could provide so I ditched Trailing Stop and often trails don’t work as well anyway?

    #107621 quote
    GraHal
    Participant
    Master

    It’s a flexible System! 🙂  Here’s another version I’ve cocked up! 🙂

    I also VRT tested it … 3rd image attached

    SAM-5.jpg SAM-5.jpg SAM-6.jpg SAM-6.jpg SAM-7.jpg SAM-7.jpg SIM-DJI-10S-v2.itf
Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Script stops buying in high volume or sudden movements


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SIMONIS @simonis Participant
Summary

This topic contains 22 replies,
has 5 voices, and was last updated by GraHal
6 years, 5 months ago.

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