Test input conditions in the optimizer

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #176132 quote
    phoentzs
    Participant
    Master

    Hello, if I want to check different input conditions with the optimization of other conditions at the same time in the optimizer, how can I do that? Is that possible? I have pre-defined different conditions and am currently always optimizing my strategies with each condition individually. Which of course costs a lot of time. So, as an example, do I want to optimize SL, TP or other conditions at the same time with cond1 or cond2 or cond3 … to find out which cond is currently the best … how can I code that so that it can be used in the optimizer?

    #176134 quote
    nonetheless
    Participant
    Master

    You can run any number of variables in the optimizer up to a max number of permutations. You just have to insert a variable in your condition for the value you want to test (eg. the period of a moving average). Then you can run it along with any other variables (stop, target, trail etc) all at once.

    I often set it up with 2-3000 permutations and leave it to run overnight.

    #176135 quote
    phoentzs
    Participant
    Master

    Yes … misunderstanding. Explained differently, as an example: cond1 = engulfing, cond2 = lowerhigh and cond3 = Close <EMA200 … how can I automatically compare these with one another in the optimizer and optimize my numerical values? Does that work? The examples are just examples.

    #176138 quote
    GraHal
    Participant
    Master
    #176141 quote
    nonetheless
    Participant
    Master

    compare these with one another

    you mean to ascertain which is most effective? you can’t do that in the optimizer, only the operative values.

    to compare them you would have to enter (or omit) them one by one to see which had the best effect.

    #176145 quote
    phoentzs
    Participant
    Master

    So the way I’ve been doing it so far. I was hoping there would be an ingenious coding trick for it.

    #176146 quote
    nonetheless
    Participant
    Master

    not that I know of!

    #176149 quote
    Swingueur
    Participant
    Average

    Hello,

    To compare different conditions in a strategy, I personally use an int optimization variable, like “strategy”, in ProBacktest module.

     

    if strategy=1 then
       entry=engulfing
    elsif strategy=2 then
       entry=breakout
    etc...
    endif
    

    This can be used in combination of other optimization variables, under the limit of combinations of course
    Is this what you want to implement?
    Fabrice

    nonetheless thanked this post
    #176160 quote
    phoentzs
    Participant
    Master

    And then enter the various strategies as conditions as numbers in the optimizer? So in the way I thought it was possible.

    #176164 quote
    Swingueur
    Participant
    Average

    Yes, “strategy” can be a variable that varies between 1 and X with increment of 1, to test different sub-strategies: entries, SL, TP (1 SL distance vs. 1.5 or 2), BE or not. etc…

    And then we use this variable in different locations in the code when needed to make some comparison and test alternative signals.

    Only thing is to note somewhere what are the meaning of the sub-strategies so that we can quickly retrieve which condition is best when the table of results is generated, and it shows that strategy=5 has better gains than strategy=9 for instance.

    #176165 quote
    phoentzs
    Participant
    Master

    That’s exactly how it sounds logical. So far I haven’t got it right. Maybe Roberto or Nicolas can help?

    #176166 quote
    robertogozzi
    Moderator
    Master

    What exactly do you want to achieve phoentzs?

    #176167 quote
    nonetheless
    Participant
    Master

    To compare different conditions in a strategy, I personally use an int optimization variable, like “strategy”

    it’s an interesting way of doing things, but do you find that it actually saves time? the optimizer is still just running them separately, one at a time, as you would do manually. Not so much optimizing as automating part of the test process … but you still have to write all the code and run each one. not sure if it will get you ahead of the game. Perhaps if you add the operative variables as well and ran it overnight – could be worth trying.

    #176178 quote
    phoentzs
    Participant
    Master

    @robertogozzi As described above. If I want to compare operational conditions in the optimizer with numerical values ​​such as SL, TP or breakeven at the same time, how can I write the conditions so that they can be processed in the optimizer? As a simple example … we have a breakout strategy and want to compare what works best: cond1 = engulfing, cond2 = higherhigh, cond3 = lowerlow and so on … what works best should be the result.

    #176189 quote
    Swingueur
    Participant
    Average

    To compare different conditions in a strategy, I personally use an int optimization variable, like “strategy”

    it’s an interesting way of doing things, but do you find that it actually saves time? the optimizer is still just running them separately, one at a time, as you would do manually. Not so much optimizing as automating part of the test process … but you still have to write all the code and run each one. not sure if it will get you ahead of the game. Perhaps if you add the operative variables as well and ran it overnight – could be worth trying.

    It may not save time for sure. I am not into running backtests overnight yet, so I don’t face such challenges.

    The main idea is to manage several alternative conditions in the same file, instead of creating several trading systems. In the end, you can reuse the conditions as a template to create other trading systems quickly, based on other indicators. It’s more an organization efficiency than pure strategy optimization.

    @phoentzs if we take some examples in your library, it could be something like this.

    https://www.prorealcode.com/prorealtime-trading-strategies/dax-m15-long-wave-diver-with-grid-and-mtf/

    ....
    c4 = (indicator5 CROSSES OVER indicator6)
    IF strategy = 2 THEN
       c4 = (indicator5 CROSSES UNDER indicator6)
    ENDIF
     
    IF c4 THEN
    SELL AT MARKET
    ENDIF
    
    ....
    lossValue = 75
    IF strategy = 3 THEN
       lossValue = 150
    ENDIF
    // Stops und Targets
    SET STOP pLOSS lossValue

    It’s basic IF ELSE statements.

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

Test input conditions in the optimizer


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 20 replies,
has 6 voices, and was last updated by SkippyTrader
3 years, 9 months ago.

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