Back Tester Help

Optuma Forums Optuma Scripting Back Tester Help

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #66969
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Hi,

    I would like to test a relative strength strategy using the GICS level 1 sectors. The idea is:
    1) Get the 126-day ROC for each sector.
    2) Buy the sectors with the top 3 ROC values.

    How do I get from my script that calculates the ROC values to an entry criteria script that chooses the top 3 values? My best guess is some form of an If statement?

    thank you

    #66973
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    Hi,

    I wouldn’t do this as a script, i’d setup a Rebalance Back Test, where the Filter was something all codes would pass (Close() > 0 for example) and the Ranking was the 126ROC value.

    You can then run the back test over the GICS Level 1 Sectors, and set the Max Positions to 3 and % per trade as 33.33%.   You can rebalance the positions as often as you wish (Weeky / Monthly, etc).

    More information here: https://help.optuma.com/kb/faq.php?id=1022

    #66977
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Thank you.  Your instructions were clear and your link was very helpful. I am happy with my results as a starting point. I would like to improve them with a filter. The example given in your link is using a moving average on an index. What if I want to do this same filter except on the open positions instead of a benchmark index? Is that possible?

    #66983
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    Hi,

    If you mean the script where the close is greater than a 50MA, you would remove the XJO Getdata() line and use only the MA reference.

    This filter will be applied to the sectors being scanned, rather than a specific index.

    #66985
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Thank you. I am sorry I didn’t ask my question clearly. The filter is a filter for entry at each rebalance. I want to add an exit criteria in order to reduce the average loss. I want to get out of a position in some cases before the rebalance. Is this possible?  Thank you.

    #66987
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    Hi,

    I believe if you change the Rebalance Positions to “On Signal” the filter script should be the trigger for the rebalance to occur.

    #66989
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Yes, switching back to the signals test type allows to script an exit, but removes the ranking which was my initial issue. I was trying to set this up as much as I could without you, but I am stuck. Below is exactly what I am trying to test. Perhaps this will help you to guide me to the best solution.

    Sector Relative Strength Portfolio Test
    Initial Entry: 01/01/1999
    ·        Rank the 11 sectors using a 126 day ROC.
    ·        Buy the top 3 with an equal dollar amount.

    Rebalance 21 or 63 days later:
    ·        Rank the 11 sectors using a 126 day ROC.
    ·        Stay long the sector if the rank is a top 3.
    ·        Exit the sector if it is not in the top 3.
    ·        Buy any sector in the top 3 that is not currently owned.

    Risk Management:
    ·        Exit a sector if the 5-day simple crosses below the 200-day simple or if there is a -30% drawdown from the high.
    ·        Re-enter if the 5-day simple crosses above the 200-day simple

    thank you

    #66994
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    Hi,

    I did not mean changing the whole backtest back to Signals, my meaning was to set the Rebalance Positions property only to On Signal…

    Ex2

    #66995
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Thank you for clearing that up. I appreciate you helping me get comfortable using the Back Tester. I am not sure that setting the rebalance positions property to on signal is exactly what I am trying to test. I believe setting the rebalance positions property to on signal stops the monthly rebalance and only rebalances based on the filter.

    What I really want to test is a monthly rebalance, but also have the flexibility to exit before a monthly rebalance if the filter triggers false and re-enter if the filter triggers true again. Is this possible to maintain a monthly rebalance and have additional exits and entries based on the filter or some other way to program this?

    Just for your information, the script I have for the criteria just asks if the benchmark index has its 3 day moving average above its 200 day moving average.

    Thank you.

    #66998
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    Hi,

    No, not at this time.  The rebalance can either be based on a set time, or based on a scripted trigger.

    The closest you would be able to get, would be to setup two scripts, one for MA cross script, another that triggers when a new month rolls over. The rebalance would occur anytime either of those two scripts triggered.

    We are working on updating the testing module overall, which should allow greater flexibility in the future.

    #66999
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    That’s great news and an interesting idea. I didn’t find anything in the forums regarding scripting a monthly trigger. How would I accomplish that? Thank you.

    #67000
    Matthew
    • Topics: 5
    • Replies: 625
    • Posts: 630

    This script would trigger each time a new month started (1st Trading Day of the month):

    #67199
    Louis
    • Topics: 38
    • Replies: 65
    • Posts: 103

    Awesome!!! Thank you.

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

Pin It on Pinterest