mql5 function shows ENUM value in debug mode "unknow enum value 65714::0

 
// Custom enumeration for trend direction

enum ENUM_IND_TREND  {

    NO_TREND=0, // No discernible trend

    UP=1,       // Uptrend detected

    DOWN=2      // Downtrend detected

};



// Input variable to choose a default trend (optional)

input ENUM_IND_TREND  default_trend = UP; // Select a default trend direction



// Global variable to store the current trend

ENUM_IND_TREND  current_trend;



//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

{

    //--- Set the initial trend based on the input variable

    current_trend = UP;

    

    string joe = EnumToString(current_trend);





    Print("Expert Advisor Initialized. Default Trend: ", EnumToString(current_trend)); // Convert enum to string for printing



    return(INIT_SUCCEEDED); // Initialization successful

}


I tested in debug mode(see attached figure).


Results:

1. current_trend  "unknow enum value 65714::1----> numerical value is corrected but don't recognize the "label"

 2. joe is a EnumToString(current_trend)----------> display correct value of ENUM.

 

The string type variable does not retain its string value in the Tester. I encountered this when I coded time filter string type input variables. My solution was to break down the hours and minutes, separately, into int type variables for processing.

Use the numerical values (StringToInteger - Conversion Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5).

Documentation on MQL5: Conversion Functions / StringToInteger
Documentation on MQL5: Conversion Functions / StringToInteger
  • www.mql5.com
The function converts string containing a symbol representation of number into number of long (integer) type. Parameters value [in]  String...
 

You're both right, and these are two common issues developers run into with MetaEditor and the Strategy Tester.

First, regarding the enum display in the debugger: the code is correct, and the value UP is properly assigned. The issue with the debugger showing strange values like 65714 is just a visual bug. The enum works as expected, and if you print the value and its string representation, you’ll see that everything is fine. So that warning can safely be ignored.

Second, about string variables in the Strategy Tester: this is also a known limitation. Input strings often don’t retain their values properly during testing or optimization, and can behave unpredictably. That’s why it’s safer to use numeric types instead. For example, instead of using a string like "09:00-17:00", it’s better to separate hours and minutes into integers. This ensures the values are handled consistently by the Tester.

Thanks for sharing both observations; they’re helpful and very relevant.

 
black_building:

I tested in debug mode(see attached figure).

Results:

1. current_trend  "unknow enum value 65714::1----> numerical value is corrected but don't recognize the "label"

 2. joe is a EnumToString(current_trend)----------> display correct value of ENUM.

I managed to reproduce this and wrote about it in a thread that developers sometimes read (they will most likely see it).

 
Vladislav Boyko #I managed to reproduce this and wrote about it in a thread that developers sometimes read (they will most likely see it).

Thank you very much, Vladislav. That's right, I'm sure something like this won't go unnoticed.

Between us, new release announcement (where bugs, suggestions, etc. are usually reported), usually get more attention from the developers and the administration.

So yes, definitely (and even more so if you posted it on the Russian forum), it will be an excellent contribution.

Благодарю ещё раз. (Thanks again.)