Is it possible to avoid many "ors" (||) in conditions causing the same action?

 

None of the operators fit. Is there any other way without if(A || B || C || D || E) Action;?

I ask moderators not to send to general questioner thread due to importance of question I am thinking about and can't find more rational solution! Thank you!

 

can simply be in Boolean variables, e.g.

X=A || B;

X=X || C || D;

X=X || E;

if (X) Action;

 
Avals:

can simply be in Boolean variables, e.g.

X=A || B;

X=X || C || D;

X=X || E;

if (X) Action;

Thank you for your feedback! And these bools can be quite complex, involving many parameters depending on constantly changing market conditions?
 
borilunad:
Thank you for your feedback! And these bools can be quite complex, depending on constantly changing market conditions?


of course

 
Avals:


of course

Thanks again! I'm going to try it now!

Looked in the Dock and saw:

bool a = true;
bool b = false;
bool c = 1;

а = (isCloseLastPosByTake() == True && Profit > ProClo / clo - GetProfitCloseLastPosByTake() * clo);
Can a boolean a be given this value?

 
borilunad:

Thanks again! I'm going to try it now!

Looked in the Dock and saw it:


You can, but the speed drops a lot.
 
Vinin:

You can, but the speed will drop drastically.
Isn't the speed affected by the "or" in if()?
 
borilunad:
Isn't the speed affected by the "or" in if()?

Of course they do. You have to check it.
 
Vinin:

Of course they do. It has to be checked.
But if you can't find something fast, then I'll stick with if()! I've already reduced the slowdown noticeably by removing unnecessary checks for me in all functions. Thank you very much for your attention! I'll be happy to learn and check all possible options!
 

You can also optimise calculations in this way:

    bool M = false;

    if (A) M = true; else if (B) M = true; else if (C) M = true; else if (D) M = true; else if (E) M = true;
    if (M) Action;
 

Or like this:

    bool M = true;

    if (!A) if (!B) if (!C) if (!D) if (!E) M = false;
    if (M) Action; 
Reason: