How about Enumerations ?
enum gv_type { gvt_buy=0,//Buy gvt_sell=1,//Sell gvt_buy_stop=2,//Buy Stop gvt_sell_stop=3,//Sell Stop gvt_buy_limit=4,//Buy Limit gvt_sell_limit=5,//Sell Limit gvt_deposit=6,//Deposit gvt_withdrawal=7//Withdrawal }; struct GV_PAIR { string Symbol; gv_type Type; double Lot; datetime OpenTime; double StopLoss; double TakeProfit; };
Agree that enumerations are a way to deal with Global Variables (GV).
I probably have to "enum Symbol" instead of "string symbol" as well if i want to store symbol in the value of GV.
Need to test if i need to "double to int" before comparing value stored in GV to the enum.
I suppose i need to work around it as such. Code dont feel right..... but a work around nonetheless...
struct STRUCT_GV_PAIR_NAME { string Name; // Pair Name string Pair; // Pair Number string iMargin; // Initial Margin string mMargin; // Maintenance Margin string Direction; // Direction }; struct STRUCT_GV_PAIR_VALUE { double Name; // Pair Name double Pair; // Pair Number double iMargin; // Initial Margin double mMargin; // Maintenance Margin double Direction; // Direction };
Hi,
Read the following https://www.mql5.com/en/forum/168741
It says that i cant have a nested struct.
I wast trying something like the following.
The code you posted compiles just fine.
struct STRUCT_GV { string Name; // GV Name double Value; // GV Value double Time; // GV Time Last Accessed }; struct STRUCT_GV_PAIR { STRUCT_GV Name; // Pair Name STRUCT_GV Pair; // Pair Number STRUCT_GV iMargin; // Initial Margin STRUCT_GV mMargin; // Maintenance Margin STRUCT_GV Direction; // Direction };
Try that in Visual Studio as a Struct. Your going to get errors and warnings.
Guys,
My bad. Alain is right.
It compiles all right.
If I used the following in OnInit, it compiles okay. I used it in the variable definition portion, causing the error. My bad. Sorrie.
EURUSD[0].Direction.Value=1.0;
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Read the following https://www.mql5.com/en/forum/168741
It says that i cant have a nested struct. I wast trying something like the following.
Intending to use
The motive is to work easier with Global Variables. I do see the GlobalVariableXXXX() functions... but I am trying to understand if there are best practices / libraries for working with Global Variables.
Global Variables appears to be a method to have inter EA communication within same account. (Please enlighten if otherwise).
Any guidance?