English

## Feature Request – Access Global Variables by Index

 9 anon 2014.05.29 09:00   Problem – Global Variable Search Time The time required for searches of global variables is at least an order of magnitude slower than accessing variables through an array. Testing has shown it to be at least 40 times faster to directly read from a double data type array of global variable values than using the standard GlobalVariableGet function.  EA uses several thousand global variables with tens of thousands of calls to global variable functions per tick per chart. When using multiple charts for testing the search time required to access global variables is considerable as there are tens of billions of global variable function calls for variable M1 HLOC testing of a one-week data period. Feature Request – Access Global Variables by Index It would be very useful if new function implementations could be added to the compiler so that there is direct read/write access by index value to the global variables stored in the memory of a terminal instance. The implementation could be as follows: int GlobalVariableIndex(const string gvariable_name)  Function returns the index value of the global variable. [2 of 2] bool GlobalVariableCheck(int gvariable_index) Function return is the same as for implementation [1 of 2].  [3 of 3] double GlobalVariableGet(int gvariable_index)  Function return is the same as for implementation [1 & 2 of 3].  [2 of 2] datetime GlobalVariableSet(int gvariable_index, double value)  Function return is the same as for implementation [1 of 2]. [2 of 2] bool GlobalVariableSetOnCondition(int gvariable_index, double value, double check_value)  Function return is the same as for implementation [1 of 2]. [2 of 2] int GlobalVariableDel(int gvariable_index) Function return is the same as for implementation [1 of 2]. [2 of 2] datetime GlobalVariableTime(int gvariable_index) Function return is the same as for implementation [1 of 2]. [2 of 2] bool GlobalVariableTemp(int gvariable_index) Function return is the same as for implementation [1 of 2]. [2 of 2] int GlobalVariableDeleteAll( int index_start,                   // start of global variables index range int index_finish,                  // finish of global variables index range datetime limt_data=0)        // as per [1 of 2] Function return is the same as for implementation [1 of 2]. Future Considerations – Improved Global Variables  Data Types It would also be useful if global variables could be any of the standard data types – e.g. bool, char, int, string, etc. This could be implemented cheaply if global variables are assigned an octet or quartet as a property array dimension.  System and Network Access Also of utility would be if a terminal instance could be linked to other terminal instances by having real-time read/write access to the global variables stored in memory of any other terminal instance whether on the same computer system or over multiple computer systems on a network.
 13118 WHRoeder 2014.05.31 15:54 #   anon: EA uses several thousand global variables with tens of thousands of calls to global variable functions per tick per chart. The purpose of (terminal) global variables is for inter-EA communications. There is no need to have more than a few. One mutex, one to many EA on chart/period about to open for A) detecting duplicate EA on another chart, or B) opening different trades by reducing lot size still keeping maximum account risk.They can be used as a poor man's persistent storage for restart recovery. If you have more than a few, you should be storing them in a file.If you have thousands your design is wrong. Should be in static or globally declared variables.Don't need to check things every tick. Figure out what you have and when something will change (new bar, or price level) only do the minimum necessary per tick.
 9 anon 2014.06.03 09:02 #   WHRoeder: The purpose of (terminal) global variables is for inter-EA communications. There is no need to have more than a few. One mutex, one to many EA on chart/period about to open for A) detecting duplicate EA on another chart, or B) opening different trades by reducing lot size still keeping maximum account risk.They can be used as a poor man's persistent storage for restart recovery. If you have more than a few, you should be storing them in a file.If you have thousands your design is wrong. Should be in static or globally declared variables.Don't need to check things every tick. Figure out what you have and when something will change (new bar, or price level) only do the minimum necessary per tick. 1. EA design is great as testing and live results have shown. 2. The post is about improving access speed to global variables. 3. You haven't addressed the issue of access speed to global variables and that is why your response is irrelevant. 4. Read the post properly and you may learn something.