i think you have to have a ; after the 2nd }
EDIT: confirmed. I have my enum like this. Note the colon after the 2nd bracket. (no errors after compiling).
enum choice { thisOne, orThisOne, ornoThisOne };this is on the Global environment.
i think you have to have a ; after the 2nd }
EDIT: confirmed. I have my enum like this. Note the colon after the 2nd bracket. (no errors after compiling).
Thanks for your response Charles.
However, my question is not on the syntax...
My question is: Where in the EA can I declare the enum so that I have access to it in all classes of the EA.
E.g. Let us same I have my project structure like this:
MAIN EA
Order_Class - this is a class used in the Main EA.
I will like to declare an enum that I can use in both MAIN EA file and Order_Class file.
Thanks in advance.
I am trying to define a custome enum so that I can use it throughout my EA.
e.g. if I have an enum like this:
enum DIRECTION {BUY, SELL,BUYANDSELL}
I want to be able to reuse this enum throughout the EA without having to declare it at every class file.
I have tried definining it in one of the classes and then declare it in the main EA but it does not work.
E.g if I define the above in a class call Utilities
Then in the MAIN EA -
I declare something like:
Utilities utility = new Utilities();
Utilities.DIRECTION direction;
The above way however does not work... it is not recognized an
I got the following compile error:
'.' - name expected
Please help
Why not actually look at all the error messages and make life easier for everyone including yourself?
You also got an error message that said: semicolon expected fix that first by adding the semicolon.
enum DIRECTION {BUY,SELL,BUYANDSELL};
Thanks for your response Charles.
However, my question is not on the syntax...
My question is: Where in the EA can I declare the enum so that I have access to it in all classes of the EA.
E.g. Let us same I have my project structure like this:
MAIN EA
Order_Class - this is a class used in the Main EA.
I will like to declare an enum that I can use in both MAIN EA file and Order_Class file.
Thanks in advance.
i did. note on the bottom line "this is on the Global environment".
Thanks for your response Charles.
However, my question is not on the syntax...
I will like to declare an enum that I can use in both MAIN EA file and Order_Class file.
Thanks in advance.
Ok so you have the class in a separate include file...
In that case you have the usual problem that when editing the class file it does not see the global scope of the EA file that will include the class and therefore the enum definition.
The correct solution is that the class should be stand alone and not rely on items from the global scope of another program. Therefore, you should define the enum in the class file if it is required. This means you will also need to define it in the EA also, but that is the correct way as the class is independent.
One way to implement this is to have a separate include file that contains the shared enum definition. Then include that file at the top of the global space in both the EA and the class file.
Ok so you have the class in a separate include file...
In that case you have the usual problem that when editing the class file it does not see the global scope of the EA file that will include the class and therefore the enum definition.
The correct solution is that the class should be stand alone and not rely on items from the global scope of another program. Therefore, you should define the enum in the class file if it is required. This means you will also need to define it in the EA also, but that is the correct way as the class is independent.
One way to implement this is to have a separate include file that contains the shared enum definition. Then include that file at the top of the global space in both the EA and the class file.
ok. well i only done that 2 or 3 times ever, but wouldnt you put it on global scope of the include file and make sure that you state that before the class where you want to use it in the ea?
i have added this thread to my favs so that i will learn something.
Ok so you have the class in a separate include file...
In that case you have the usual problem that when editing the class file it does not see the global scope of the EA file that will include the class and therefore the enum definition.
The correct solution is that the class should be stand alone and not rely on items from the global scope of another program. Therefore, you should define the enum in the class file if it is required. This means you will also need to define it in the EA also, but that is the correct way as the class is independent.
One way to implement this is to have a separate include file that contains the shared enum definition. Then include that file at the top of the global space in both the EA and the class file.
Paul,
Thanks for your guidance. You really know what I need.
I have declared the enum in another file and included it in the top of the top of the global space in both EA and class but I still cannot get it to work.
I have included the codes for the two files here...
when I tried to declare a variable of type enum DIRECTION in the main EA, I am getting this error messages:
mainEADirection undeclared identifier
DIRECTION undeclared identifier
DIRECTION some operator expected
// This is in a separate class file called Utilities.mqh #property copyright "xxxxx" #property link "" #property version "1.0" // below is being used by algoTrading Status function #define MT_WMCMD_EXPERTS 32851 #define WM_COMMAND 0x0111 #define GA_ROOT 2 #include <WinAPI\winapi.mqh> class Utilities { private: struct uEvt { datetime eDate; string eDescription; ulong eCountryCode,eID; } uEvents[]; protected: public: enum DIRECTION {SELL =0,BUY = 1,BUYandSELL}; Utilities() {}; ~Utilities() {}; ///======================= END of Utilities class file ======= // this is my global EA Space of the main EA file AutoPOI.mq5 #property version "1.03" //+------------------------------------------------------------------+ #include "Commontasks\Utilities.mqh" Utilities utility = new Utilities(); int OnInit() { return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //delete utility; } //+------------------------------------------------------------------+ void OnTick() { // this is just a trial example... Print(utility.SELL); // this works fine. SELL is part of DIMENTION enum mainEADirection DIRECTION; // I will like to declare a variable of type enum DIRECTION for use here in the main EA // but am getting an error message... }
Thanks all,
the correct syntax should be
Utilities::DIRECTION mainEADirection;
This closes the message trail

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to define a custome enum so that I can use it throughout my EA.
e.g. if I have an enum like this:
enum DIRECTION {BUY, SELL,BUYANDSELL}
I want to be able to reuse this enum throughout the EA without having to declare it at every class file.
I have tried definining it in one of the classes and then declare it in the main EA but it does not work.
E.g if I define the above in a class call Utilities
Then in the MAIN EA -
I declare something like:
Utilities utility = new Utilities();
Utilities.DIRECTION direction;
The above way however does not work... it is not recognized an
I got the following compile error:
'.' - name expected
Please help