The other EA's don't change the counter, each EA has it's own instance of the counter, set to one in it's OnInit().
If you want one counter shared by all EA's you can use Terminal global variables
Documentation on MQL5: Language Basics / Variables / Global Variables
- www.mql5.com
Global variables are created by placing their declarations outside function descriptions. Global variables are defined at the same level as functions, i.e., they are not local in any block. The scope of global variables is the entire program. Global variables are accessible from all functions defined in the program. They are initialized to zero...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am having an issue which I suppose should be extremely simple but I cannot solve it. Here is my EA:
int counter = 1;
OnTick(){
do stuff with counter;
}
My problem is, every time I launch another EA on a different pair, it changes my counter back to 1 in every EA. Obviously I know this is because the variable is global, but the only command I can find for making the variable local is "static" and I have tried it without success. I cannot set the counter inside OnTick because it would constantly reset it every tick. So my problem is creating a variable which is global only to this EA but not being changed by all the other EA's on other pairs.