Question about Logical Operation && without an if comparison ?

 
I know the reference and book does not mention this but curious how it works for assignment instead of comparison. 

Can this even be done as intended ? 

For example:

extern bool      chart_period=true; //
extern bool      macdm1=false;
extern bool      macdm5=false;
extern bool      macdm15=false;
extern bool      macdh1=false;
extern bool      macdh4=false;
extern bool      macdd1=false;

string selections;


void selection()  //perhaps better for switch and case. 
   {
   if(chart_period && !macdm1 && !macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections="histo()";
   if(chart_period && macdm1 && !macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections="histo() && histo_M1()";
   if(chart_period && macdm1 && macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections="histo() && histo_M1() && histo_M5()";
   
   } 
These are bools in the comparisons. Not sure how to convert back to use for a comparison. 

Or if I should be using "bool selections" instead but I'm not sure how Logical Operation && views this without "if" ?

For example instead:
extern bool      chart_period=true; //
extern bool      macdm1=false;
extern bool      macdm5=false;
extern bool      macdm15=false;
extern bool      macdh1=false;
extern bool      macdh4=false;
extern bool      macdd1=false;

bool selections;

void selection()  //perhaps better for switch and case. 
   {
   if(chart_period && !macdm1 && !macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections=histo();
   if(chart_period && macdm1 && !macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections=histo() && histo_M1();
   if(chart_period && macdm1 && macdm5 && !macdm15 && !macdh1 && !macdh4 && !macdd1)
   selections=histo() && histo_M1() && histo_M5();
   
Is the && use even a valid option ? and if so what is the assignment if it can even be used like this. 

I know the references and book only show examples of if(&&) comparisons and I understand it's used that way but never considered if possible to use in an assignment if it can even be done. 

Please advise and educate me on this please. 
Thanks
 
Agent86: Or if I should be using "bool selections" instead but I'm not sure how Logical Oeration && views this witout "if" ?

If statement is irrelevant. if(bool) is the same as bool isSel=bool; if(isSel);.
          Increase Order after stoploss - MQL4 programming forum #1.3 (2017)

You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.
 
William Roeder #:

If statement is irrelevant. if(bool) is the same as bool isSel=bool; if(isSel);.
          Increase Order after stoploss - MQL4 programming forum #1.3 (2017)

You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.

Yes, I seem to be going in circles and/or working myself in a corner.  

This code was based on my idea of multiple selections
https://www.mql5.com/en/forum/451149


I thought I might select properties and then when each property is true to assign the proper indicator or bool comparison to that. 

Such as selections = bool && bool;  or selections = bool && bool && bool

if(selections) code
if(!selections) code

This way instead of changing the comparison I could change it dynamically from the properties by selecting true or false etc. 

I couldn't think of anything else to make a dynamically changed comparison.

Thanks for the replies. 

 

need example / advise how method for makeing multiple selections or multiple properties.
need example / advise how method for makeing multiple selections or multiple properties.
  • 2023.07.21
  • www.mql5.com
I'm asking generically for concept ideas because I don't really understand where to start...
 
I'm confusing myself. 

What data type can be used as literal text as if I were typing the function name or variable name into the comparison manually ?

I thought a string might do this or to assign a variable with the same typed text but I see now this is not as I intended it.