Enum

 
enum WaveNoB
  {
   W3,  
   W_3,  
   W4, 
   W_4,
   W5,
   W_5  // 
   
  };
  
extern WaveNoB WaveLong = W3;

   double delka2=W2*Waves/10000 ;
   double delka_2=W_2*Waves/10000;
   double W3= W2+delka2;
   double W_3= W_2-delka_2;

ObjectCreate("VBox1s3", OBJ_LABEL, "X", 0, 0);
ObjectSetText("VBox1s3","Long TP  "+DoubleToString(WaveLong,5)+"  Long SL  "+DoubleToString(W_5,5) ,11, "Baskerville Old Face", White);
ObjectSet("VBox1s3", OBJPROP_CORNER, 1); // CORNER MEANS POSITION ON THE CHART 1-4
ObjectSet("VBox1s3", OBJPROP_XDISTANCE, 20); // XDISTANCE
ObjectSet("VBox1s3", OBJPROP_YDISTANCE, 40); // YDISTANCE
I need advice, double to string is obviously wrong, what should I write to show the value, in this case W3? Thank you
 
string as_string(WaveNoB no){ return EnumToString(no); }
 
thanks, sorry, I don't understand how to incorporate it, could you rewrite it as for a complete amateur please?
 
Zbynek Liska #:
thanks, sorry, I don't understand how to incorporate it, could you rewrite it as for a complete amateur please?

enum WaveNoB {
   W3,  
   W_3,  
   W4, 
   W_4,
   W5,
   W_5
};
  
extern WaveNoB WaveLong = W3;

double delka2  = W2 * Waves / 10000 ;
double delka_2 = W_2 * Waves / 10000;
double W3      = W2 + delka2;
double W_3     = W_2 - delka_2;

ObjectCreate("VBox1s3", OBJ_LABEL, "X", 0, 0);
ObjectSetText("VBox1s3", "The value selected is  " + as_string(WaveLong), 11, "Baskerville Old Face", clrWhite);
ObjectSet("VBox1s3", OBJPROP_CORNER, 1); // CORNER MEANS POSITION ON THE CHART 1-4
ObjectSet("VBox1s3", OBJPROP_XDISTANCE, 20); // XDISTANCE
ObjectSet("VBox1s3", OBJPROP_YDISTANCE, 40); // YDISTANCE

string as_string(WaveNoB no) {
        return(EnumToString(no));
}
 
thank you, it gives this error, I will solve it via if else
 
Zbynek Liska #: , it gives this error, I will solve it via if else
  1. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.


  2. You "can't solve it via if else."

    MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

 
Zbynek Liska #: thank you, it gives this error, I will solve it via if else

Please take some time to first learn the basics of coding in general.

For now just use the following instead ...

ObjectSetText("VBox1s3", "The value selected is  " + EnumToString(WaveLong), 11, "Baskerville Old Face", clrWhite);
 
Fernando Carreiro #:

Please take some time to first learn the basics of coding in general.

For now just use the following instead ...

Thank you, this is exactly what I tried first and it showed the value 0, probably the first in the sequence, so it already shows W3, is there a way to show the value of the calculation that is in the formula for w3?   I don't want to delay, I made it work through if else
 
Zbynek Liska #: Thank you, this is exactly what I tried first and it showed the value 0, probably the first in the sequence, so it already shows W3, is there a way to show the value of the calculation that is in the formula for w3?   I don't want to delay, I made it work through if else

You are mixing up concepts.

In your code you have variables of the double data-type, named "W3" and "W_3", and you also have an enum with an elements with the same names "W3" and "W_3". Even though you named them the same thing, they are complete different concepts.

You mixing them up because you still don't know the basics of coding, both in general and regarding MQL.

So, please take some time to improve your knowledge about coding basics first before continuing.

 
Fernando Carreiro #:

You are mixing up concepts.

In your code you have variables of the double data-type, named "W3" and "W_3", and you also have an enum with an elements with the same names "W3" and "W_3". Even though you named them the same thing, they are complete different concepts.

You mixing them up because you still don't know the basics of coding, both in general and regarding MQL.

So, please take some time to improve your knowledge about coding basics first before continuing.

ok, thank you very much for your time, so I'll leave it in the if else version, where it works great, I leave the more complicated things programmed, I wanted to try this myself, mainly because I got it working :)
 
Is there no EnumToString() in MQL4?
Reason: