Time entry condition with stop orders

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #160096 quote
    nonetheless
    Participant
    Master

    I have an algo with the following definition of opening times:

    Ctime = time >=080000 and time <163000

    the entry conditions are:

    if Ctime  and not onmarket or longonmarket and cb1 and cb2 and barindex-tradeindex(1)>=LookbackPeriod  then
    BUY positionsize CONTRACTS AT highest[LookbackPeriod](high)+PointsDistance*pointsize STOP
    SET STOP pLOSS sl
    SET TARGET %PROFIT tp
    endif
    
    if Ctime and not onmarket or shortonmarket and cs1 and cs2 and barindex-tradeindex(1)>=LookbackPeriod then
    SELLSHORT positionsize CONTRACTS AT lowest[LookbackPeriod](low)-PointsDistance*pointsize STOP
    SET STOP pLOSS sl
    SET TARGET %PROFIT tps
    endif

    but I find it is placing orders outside of the Ctime definition.

    I presume this is due to the system placing Stop Orders – and if this is the case, is there any way to restrict a stop order to only work within that time definition?

    #160100 quote
    robertogozzi
    Moderator
    Master

    The issue is in the icorrect placing of parentheses, try this:

    if Ctime and (not onmarket or longonmarket)  and cb1 and cb2 and ((barindex-tradeindex(1))>=LookbackPeriod) then
    if Ctime and (not onmarket or shortonmarket) and cs1 and cs2 and ((barindex-tradeindex(1))>=LookbackPeriod) then
    nonetheless thanked this post
    #160103 quote
    nonetheless
    Participant
    Master

    thanks Roberto, I’ll try that.

    #160106 quote
    nonetheless
    Participant
    Master

    Hmm, one small problem – this completely destroys the performance. It goes from being highly successful to total disaster.

    Is the way I originally had it seriously wrong? ie, giving false results?

    #160107 quote
    robertogozzi
    Moderator
    Master

    No, it only enters outside your time range. If this is good for you, then it’s fine.

    Bear in mind that outside that time range spreads may be higher (and rquired distances from price as well). This might impact peformance.

    #160111 quote
    nonetheless
    Participant
    Master

    outside that time range spreads may be higher

    Yes, this was the main problem. It works with a tiny stop loss of just 5 points, but overnight the DAX minimum goes up to 10 so orders get cancelled and then the system gets stopped.

    But now I realize there’s a bigger problem: the way i originally had it doesn’t work anymore either. Last week it was fine, showing massive profit over 10 years, now it breaks the bank almost immediately – exact same code, unchanged. Unfortunately I didn’t keep a print of the results I was getting.

    So the disaster is not due to the changes you suggested, but some weirdness in the PRT backtests.

    I’ve attached the itf if anyone wants to make further tests because i have no idea what is going on here.

    DAX-15m-Breakout-v4-atr.itf
    #160124 quote
    robertogozzi
    Moderator
    Master

    On DAX, 1-hour TF (200K bars), 2-pip spread, it’s not that bad! (it worked similarly on the 30-minute and 15-minute TF).

    I used my modifications and reaplaced TIME with OPENTIME.

    Bear in mind that 8-16:30 is a bit different for me, it’s 7-15:30 UK.

    #160135 quote
    nonetheless
    Participant
    Master

    This is making my head spin – suddenly it tests ok again, with absolutely no changes! (v4)

    Also with your change to the ( ) now works. The profit drops as expected due to the time limit, but still acceptable. (v5T)

    Molto misterioso …

    DAX-15m-Breakout-v4-atr.jpg DAX-15m-Breakout-v4-atr.jpg DAX-15m-Breakout-v5T-atr.jpg DAX-15m-Breakout-v5T-atr.jpg
    #160141 quote
    robertogozzi
    Moderator
    Master

    It must be mood dependent! 😂

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

Time entry condition with stop orders


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by robertogozzi
5 years ago.

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