Download MetaTrader 5
To add comments, please log in or register
Add our Twitter channel to friends and follow the news!
Rogelio Rosales
36
Rogelio Rosales 2017.01.09 21:26 

I have a problem... I declared an array outside any function, so, the scope of this array is global.
Execute the EA and I save and load data from this array on a pair, for example EURUSD without problems but, the problem is when I execute the same Expert Advisor on 2 or more pairs, the data is combined and I don't know if the data that I´m getting is from EURUSD, GBPUSD or another one, what can I do?

Beforehand, thank you. 

 

Global scope 

Keith Watford
Moderator
9597
Keith Watford 2017.01.09 21:43  

Are you sure about this?

A globally declared array is only global to the instance of the EA. It should not be possible to access that array from the same EA attached to a different chart.

Rogelio Rosales
36
Rogelio Rosales 2017.01.09 22:02  

Yes, I'm totally sure

I have been trying other simple things and this is happening

Code 

---------------------------------------------------------------------------------------------

001 

---------------------------------------------------------------------------------------------------------------------

002 

whroeder1
14457
whroeder1 2017.01.09 22:10  
Rogelio Rosales: the problem is when I execute the same Expert Advisor on 2 or more pairs, the data is combined
You are not running it on "2 or more pairs" you are switching pairs and your code only adds to the array. You never clear out on init. You'll get duplicates when you just change timeframes.
Fernando Carreiro
2354
Fernando Carreiro 2017.01.10 02:33  
Rogelio Rosales: Yes, I'm totally sure I have been trying other simple things and this is
Please note that the function OrderTotal() returns the total number of open orders for the entire account. It has no relationship with the Chart you have the EA running, so it does not filter by Currency pair or by Time-frame or by Magic number or anything else for that matter. It is simply the Total number of open orders for the entire account for all the running EAs as well as manual trades.
Rogelio Rosales
36
Rogelio Rosales 2017.01.10 21:45  
whroeder1:
You are not running it on "2 or more pairs" you are switching pairs and your code only adds to the array. You never clear out on init. You'll get duplicates when you just change timeframes.
It's true, first I executed the EA in EURUSD and next I tried it on GBPUSD 
Rogelio Rosales
36
Rogelio Rosales 2017.01.10 21:48  
Fernando Carreiro:
Please note that the function OrderTotal() returns the total number of open orders for the entire account. It has no relationship with the Chart you have the EA running, so it does not filter by Currency pair or by Time-frame or by Magic number or anything else for that matter. It is simply the Total number of open orders for the entire account for all the running EAs as well as manual trades.
Fernando Carreiro Yes, it is a mistake from me, sorry

But I did it  for try to explain my topic, in few words, I need create an array for every pair when the EA is running so the data not mixed  
Fernando Carreiro
2354
Fernando Carreiro 2017.01.10 22:26  
Rogelio Rosales: Fernando Carreiro Yes, it is a mistake from me, sorry. But I did it  for try to explain my topic, in few words, I need create an array for every pair when the EA is running so the data not mixed  

The Data does not "mix". You must be doing something wrong, so show your real code if you want us to help!

To add samples don't use screen-shots; use the SRC button in the toolbar: 

If the code is long, then attach it instead (in the bottom-left):

/
To add comments, please log in or register