Complete lack of logic over converting ENUM variables

 

The stupidity here is unbelievable at times, I have the following:

enum MinRSQ{

   RSQ10                               =  10,
   RSQ20                               =  20,
   RSQ30                               =  30,
   RSQ40                               =  40,
   RSQ50                               =  50

};

enum MaxRSQ{

   RSQ60                               =  60,
   RSQ70                               =  70,
   RSQ80                               =  80,
   RSQ90                               =  90,
   RSQ100                              =  100

};

input MinRSQ                          minRSquared                     =     20;// Maximum RSQ (%)
input MaxRSQ                          maxRSquared                     =     60;// Minimum RSQ (%)

Then, on initialization. I have the following: 

if(maxRSquared < minRSquared){
   
      MessageBox("The Maximum Correlation Coefficient is less than the Minimum Correlation Coefficient.","Correlation Coefficient Error"+HeaderInformation,MB_OK | MB_ICONERROR);
      
      return(INIT_FAILED);
   
   }

Upon compiling, I get the following:

'minRSquared' - cannot convert enum     2024.15.0.3.mq4 82      21

Why does this complete imbecilic piece of software have no problem converting "maxRsquared" but has a hissy fit about converting "minRsqaured", despite them both being of ENUM type?

Absolutely, unbelievable. Logic beggars belief. 

 
TheHonestPrussian:
if(maxRSquared < minRSquared)

What is the point of this check? You have declared 2 enums in such a way that any max value will always be greater than any min value.

 
TheHonestPrussian:

The stupidity here is unbelievable at times, I have the following:

Then, on initialization. I have the following: 

Upon compiling, I get the following:

Why does this complete imbecilic piece of software have no problem converting "maxRsquared" but has a hissy fit about converting "minRsqaured", despite them both being of ENUM type?

Absolutely, unbelievable. Logic beggars belief. 

Why bother with an enum if you are going to assign values rather than use the enum.

 
Vladislav Boyko #:

What is the point of this check? You have declared 2 enums in such a way that any max value will always be greater than any min value.

It does not matter what the point is.

No I have not, they're user specified; if the user sets a minimum restriction that is greater than the maximum restriction then the EA will deinitialise. 

Now, are you going to continue to ask more questions or are going to provide some insight as to why MT4 has decided it's going to be an arse?

 
Paul Anscombe #:
Why bother with an enum if you are going to assign values rather than use the enum.

Give me strength..

Because they're predetermined values
 
TheHonestPrussian #:

Give me strength..

Because they're predetermined values
Try doing it properly. See what result you get
 
TheHonestPrussian:
Why does this complete imbecilic piece of software have no problem converting "maxRsquared"

The error message depends on the order of the variables in the expression.

Swap the variables and get the same error message, but with a different variable:

if(minRSquared < maxRSquared) // 'maxRSquared' - cannot convert enum

It doesn't matter which variable is mentioned in the error message. The error lies in the idea of ​​comparing the values of variables belonging to two different enumerations.

If you are using 2 different enums to limit the user's choice of values, then explicitly cast these enums to type int or long when comparing them:

if((int)maxRSquared < (int)minRSquared) // OK
 
Paul Anscombe #:
Try doing it properly. See what result you get

It's the result I just showed you - you know, because of the whole "me doing it properly" thing I've got going on here. 

So, why - despite me doing it property - is MQL4 decided that this is going to be added to the list of things that is deciding to piss me off and make my life difficult?

Swear to God I have a great big neon sign above my head that is only invisible to me, with a great big arrow that points to my head and says "Please make this persons life a difficult as possible

 

Everyone, take note of @ Vladislav Boyko's answer here

This is how you answer a question: not by stupid irrelevant questions. not by passive aggressive bullshit. If everyone actually applied @ Vladislav Boyko's thinking here - this forum would be such a nightmare. 

Thank you @ Vladislav Boyko

Vladislav Boyko
Vladislav Boyko
  • 2024.03.16
  • www.mql5.com
Trader's profile
 
TheHonestPrussian #:

It's the result I just showed you - you know, because of the whole "me doing it properly" thing I've got going on here. 

So, why - despite me doing it property - is MQL4 decided that this is going to be added to the list of things that is deciding to piss me off and make my life difficult?

Swear to God I have a great big neon sign above my head that is only invisible to me, with a great big arrow that points to my head and says "Please make this persons life a difficult as possible

Just use the enum identitfiers instead of 20 and 60
 
Vladislav Boyko #:

The error message depends on the order of the variables in the expression.

Swap the variables and get the same error message, but with a different variable:

It doesn't matter which variable is mentioned in the error message. The error lies in the idea of ​​comparing the values of variables belonging to two different enumerations.

If you are using 2 different enums to limit the user's choice of values, then explicitly cast these enums to type int or long when comparing them:

Everyone, take note of this answer.

This is how you answer a question: not by stupid irrelevant questions. not by passive aggressive bullshit. If everyone actually applied this persons thinking here - this forum would be such a nightmare. 

Thank you @ Vladislav Boyko, much appreciated and all the best to you. 

Vladislav Boyko
Vladislav Boyko
  • 2024.03.16
  • www.mql5.com
Trader's profile
Reason: