In general I think it is easier to use just one file per EA - assuming you only have one position open at any given time per EA.
This article on using html to help organize records might be useful to you (if you haven't already seen it) : https://www.mql5.com/en/articles/1432
Regarding unique file names, I often use one composed of two parts: 1) the description given to the EA strategy, and 2) the unique number of seconds when the EA was initiated. Eg. "Stochastic EA (1346244900)"
The unique number of seconds is found by getting the integer value for TimeLocal() (NOT TimeCurrent()!) when the EA is initiated. This value is stored for the life of the EA (as an internal variable or as a GlobalVariable) and referred to every time the file is accessed.
Since it is unlikely that two EAs will ever be initiated in exactly the same second, it makes sure that no two files are the same, even if other details such as AccountCompany() and AccountNumber(), etc. are all the same.
There is a downside to this approach though, because the unique number of seconds is usually set during the init(). You need to make sure that the init() is not run again by mistake (such as restart after bluescreen), otherwise the EA will start an entirely new file!
I do this by having a GlobalVariable for each EA in the terminal. Once I have set the EA going, I set the relevant GlobalVariable to "1". The contents of the init() are in a conditional which checks that GlobalVariable to make sure it is "0" before it runs.
There is probably a better way, but this is one possibility.
It is to preserve through the pressing of F7 and change of period on the chart or the user could change the currency pair and then go back again along with the "your computer has been updated" issues.
but once you start using a file to save data you run into multiple uses of the same EA and logging into different accounts!
Thanks for the article.
I'm inclined to go for the eaname.dat file allowing multiple intances of the same ea.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Life gets a LOT more interesting when you start saving values to a file.
1) take care of EA working on more than one chart.
2)File maintenance.
In issue one - New file for each new ticket identified by ticket number or Maintan one file with each line holding ticket data.
Many files - have to find old filenames of closed tickets not deleted when ticket closed. But also checking that they belong to account logged into as well!
For unique identification I must use AccountCompany() and AccountNumber() and OrderTicket() - Am I missing anything?
Which is the easiest route to follow?
What is the chance that the single file will be accessed by one chart locking out another chart how do I check for this error?.