Optimization and combinations of opening conditions, is there a simple workaround to my problem ?

 

Hello all,


I'm trying to run an optimization procedure to easily go through all my opening conditions, which are numerous, and check which combination of opening conditions are the best.


For that I just used boolan inputs and added a additional conditions in buy/sell conditions as you can see in code below. However, with this method a position is only opened when all conditions are met (i.e. when no "useIndicator" is set to false) as you can see in picture attached. What I want is spanning all opening conditions, so that a "useIndicator= false" only exclude that conditions and let other true conditions being used.


Is there a simple workaround to that problem, maybe using some other logic in the buy/sell conditions ? Or do I have to insert some conditional if/else statement, which could be hard with a high number of conditions ?


Best regards,

Ostinato

input bool               useFast1MA                  = true;         // Enable/disable Fast1 MA condition

input bool               useFast2MA                 = true;          // Enable/disable Fast2 MA condition

...

   buyCondition  = (

                     (p_close > BufferFast1MA[1]) && useFast1MA

                    && (p_close > BufferFast2MA[1]) && useFast2MA
Files:
why.png  11 kb
 

What about:

buyCondition  = (

                     (p_close > BufferFast1MA[1] && useFast1MA)

                    || (p_close > BufferFast2MA[1] && useFast2M)
                ) { ...

?

 

Thanks for your answer, using OR means any single condition can open a trade independently. What I want however is try all combinations of opening conditions and check how restrictive I should be by adding more or less conditions to open a trade. So it is not working unfortunately. 


Is there another logical symbol that would be the equivalent of "AND + exclude if FALSE" ?

 

Hi

I think your solutions is not the best way to do this. Please note that if you set one of the conditions as false the whole signal always be false (since you use AND operators (so if any of the values is false the whole buyCondition is false).

What you are looking for is the condition that allow partial conditions confirm signal when they are not used or when used give signal only when they have corrected values.

So you need to write something like this:

buyCondition  = (

 

                     ((p_close > BufferFast1MA[1]) || !useFast1MA)

 

                    && ((p_close > BufferFast2MA[1]) || !useFast2MA)
                                            && ….

                               )

This way you either wait for condition to be met from first chosen rule (p_close>BufferFast1MA[1]) or if not used (!useFast1MA) allow trading)

Best Regards

 

Waow it worked perfectly, really impressive thanks a lot !!