Script (for Backtester) to Exit After x No. of Days

Optuma Forums Optuma Scripting Script (for Backtester) to Exit After x No. of Days

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #58855
    AvatarIan
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Hi,

    I would like to backtest some candlestick patterns, with an exit after a certain number of days, eg. 3, 4 or 5 days.

    I’ve tried the TIMESINCESIGNAL function for the exit, but when checking the Trade List produced, the exits seem to be on the next trading day. Either I’ve got the Test Rule parameters wrong in the Backtester, or the script wrong. This is the Exit Criteria script I tried:

    (Entry Criteria)

    #58857
    MathewMathew
    • Topics: 32
    • Replies: 1,590
    • Posts: 1,622

    Hi Ian,

    In the properties of the Backtester there is an option called “Max Hold Time” just change that to the number of days you want to hold for. Then you do not need an exit script.

    All the best

    Mathew

    #58871
    AvatarIan
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Thanks Mathew,

    From the Optuma Knowledge Base,

    https://help.optuma.com/kb/faq.php?id=735

    there is mention of the Min Hold Days and Max Hold Days, although the screenshot below shows only Min Hold Days.

    BackTester_KB

    However, the Backtester dialog box I have doesn’t seem to show either Min Hold Days or Max Hold Days. (Screenshot below.)

    BackTester_IJ.JPG

    Am I missing something?

    #58873
    DarrenDarren
    • Topics: 62
    • Replies: 503
    • Posts: 565

    Thanks Ian. Those min/max hold day options are only available with a Professional or Enterprise Services subscription, and not with Trader Services.

    As such, your exit script can be defined as follows for 5 days after the entry:

    If you plan on doing lots of these types of tests then the Signal Testing add-on module may be an option for you. Click here for more info (including videos).

    As an example, here’s the Bullish Engulfing signal test results for the 71 SPX events over the last 10 years, looking 5 days before and 22 days after each occurrence:

    Capture

    #58891
    AvatarIan
    • Topics: 4
    • Replies: 5
    • Posts: 9

    Thanks Darren.

    I tested that and got what seemed to be correct results.

    I used as the entry criteria:

    And as the exit criteria:

    If I want to include extra entry criteria such as volume, would that just go in the Entry Criteria section?

     

    #58897
    DarrenDarren
    • Topics: 62
    • Replies: 503
    • Posts: 565

    Correct – just add the extra filters to the last line of the entry criteria, such as ‘and VOL()>100000’ for volume, or ‘and CLOSE()>1’ for a price-based filter.

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

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close