Backtest – Dynamic Trailing Stop

Optuma Forums Optuma Scripting Backtest – Dynamic Trailing Stop

This topic contains 4 replies, has 2 voices, and was last updated by Matthew Matthew 3 weeks, 4 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #54377
    Avatar
    Merrilee
    • Topics: 5
    • Replies: 13
    • Posts: 18

    I’m trying to get a dynamic trailing stop working in the Backtester.

    My understanding is that a trailing stop needs to go in the Stops section, not the Exit Criteria.

    The image below is the script I would really like to work – using ATR.  But the Backtester doesn’t seem to like ATRTSCAN and ignores the script.

    I also tried using a percentage stop:-

    s1 = STOP(STOPTYPE=Percent, CALC=High, TRAILING=True, STOPVALUE=10.00);

    s2 = STOP(STOPTYPE=Percent, CALC=High, TRAILING=True, STOPVALUE=40.00);

    m1 = IF(ROC(BARS=52) < MA(ROC(BARS=52), BARS=8, STYLE=Exponential, CALC=Close),s1,s2);

    CLOSE() < m1

    But the Backtester used a 10% trailing stop all of the time, regardless of my other condition.

    Where am I going wrong? Or it this even possible?

    Thanks for any suggestions.

    snip

     

    #54403
    Avatar
    Merrilee
    • Topics: 5
    • Replies: 13
    • Posts: 18

    Anyone?

    #54419
    Matthew
    Matthew
    • Topics: 4
    • Replies: 186
    • Posts: 190

    Hi,

    Have you applied the script to a chart to confirm it is doing what you expect it to there?  That’s the first step.

    If the script is working as expected (or once you’ve adjusted it to work as you want), i’d suggest not adding it to the Stops section in the back tester, it’s designed for basic stops only. Instead add it to the Exits section and place an OR between it and the other exit criteria you’ve setup.

    #54431
    Avatar
    Merrilee
    • Topics: 5
    • Replies: 13
    • Posts: 18

    Hi Matthew and thanks for your reply.

    Yes, I have tried to apply the ATRTSCAN script as above to a Show Plot and it shows nothing – I seem to remember reading somewhere that ATRTSCAN will only work in the Stops section of the Backtester.

    Below is the working script I use on my charts for the trailing stop:-

    a30 = ATR(BARS=10, MULT=1.00);

    a10 = ATR(BARS=10, MULT=5.00);

    a1 = if(ROC(BARS=52) > MA(ROC(BARS=52),BARS=8, CALC=Close, STYLE=Exponential), a10, a30);

    c1 = HIGH() – a1;

    RATCHET(c1, START=2019-02-08)

    But, the trailing stop is dependent on the START date, so how do I code the START date to automatically reflect the different dates of entry in the Backtester?

    Many thanks

    Merrilee

     

     

    #54437
    Matthew
    Matthew
    • Topics: 4
    • Replies: 186
    • Posts: 190

    Hi,

    Can you send a copy of your back testing file setup to support for review.

    The file will be found here:

    My Documents – Optuma – Local – Searches – Back Tests

Viewing 5 posts - 1 through 5 (of 5 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