you can use global variables to exchange information between EAs, e.g.:
double newLots = GlobalVariableGet("newLots");
double last_buy = = GlobalVariableGet("last_buy");
...
...
...
globalVariableSet("last_buy", OrderTicket() );
globalVariableSet("newLots", 0.7);
These variables stay stored in "terminal->tools->global variables" and can be used by any EA/script running in the terminal.
Thanks for the answer, abstract_mind. I know about global vars. But my question was about modifying external vars:
e.g. extern double myvar = ...
But I guess they can only be modified manually. :(
you didn't read well my answer:
- globalVariableSet("last_buy", OrderTicket() );
- globalVariableSet("newLots", 0.7);
I advise to also read the mql4 manuals and try understand some examples. You will hit your fingers if u try using a hammer without enough practice. Regardless u are a forex expert, you will loose money if you aren't sufficiently skilled at mql4.
Well, I've read the whole "mql4 book" but here is what i have:
Let's say my EA has the following variable:
- extern double EA_Lots = 10;
The problem is I cannot edit the EA and change the variable to global. It can only stay as it is.
So can I make another EA that changes the extern variable in the original EA?
I cannot use globalVariableSet, as the variable EA_Lots is not of global but extern type.. or can I?
If you have the source-code you can modify a variable from external to global:
//step 1 - change from extern to global
//extern double EA_Lots=10;
double EA_Lots=0.1; //still global, but without extern
// step 2 - at the begining of the start function()
int start()
{
if(GlobalVariableCheck("EA_Lots"))
EA_Lots = GlobalVariableGet("EA_Lots");
// your remaining code...
}
I've never tried, but I think you can do these changes and still leaving variable as "extern double". This way, you get both functionality: as extern variable and as terminal's global variable.
This is valid if you have got source-code. I cannot recall a solution for compiled EAs. For compiled code, I think it is not possible.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
To your attention.. a rather dumb question:
Is it possible read and alter EA external variables with other EAs/scritps? Can external variables be changed only manually?
Thanks :)