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
Here's how I do it, for what its worth.
I save to a recovery file:
- Information that the EA would need to get back in step with its signal decision making
- Information that the EA would need to get back in step with its money management strategy
- Information to validate that this recovery file is current
I do not save to the recovery file:
- Information that is persisted elsewhere such as the Trades and History lists, I tend to have my EAs read their trades out of the Trades list on init()
- Variables that the EA does not change and will automatically be applied by the platform on a reinitialisation
I name the recovery file based upon the EA name, EA version number, and Symbol/Chart.
Hope this helps.
CB
-
The problem with this approach as I see it that it doesn’t allow for the possibility of having multiple instances of the same EA on a chart on the same timeframe.
When the EAs starts up, there is only one version of the code that each instance runs and therefore the only way to initialise the charts correctly on start up is to use specific data about the chart to correctly deduce which initialisation/recovery persistent file to use. The functions that I found that can be used are Period() and Symbol() to form part of the name of the persistent data file. If the instances of the EA are running on several charts with identical symbol and period, then I don’t see any elegant solution to the EA picking the right file. Ideally I think what is needed is some MT4 function call which will return some unique feature of the chart that the EA is being attached to. Is there some other function which can identify some parameter of a chart which I can use to differentiate between two charts with same EA, period and timeframe?
The problem was highlighted to me when I realised that on compilation, the External Variables are wiped clean and not re-read from the *.chr file containing the chart specifications. I managed to get around this by detecting when initialisation was due to recompilation and then using a global variable name based on the combination of symbol_period_windowHandle. This works for the recompilation problem but won’t work between resets and crashes because the handle changes each time. The only persistent data I think I need is the EA number to distinguish between instances of the same EA. From this I can prescribe ranges for magic numbers that I use and this way I can ascertain which orders belong to which EA.
Works fine for me as my charts do not duplicate symbol/timeframe within a single MT4 instance. :-) They are spread across accounts and therefore, instances.
I'm perfectly aware of the limitations, but I like to keep things simple, whilst meeting my functional and non-functional requirements. I've never had a single operational issue (ever) with my persistence layer.
The context of the post was a discussion between fbj, jjc and myself as to how we each do things.
Regarding the use of unique identifiers, there has already been discussion on this issue - including a post within the last few days; just do a quick search down the forum and you'll find it.
CB
The context of the post was a discussion between fbj, jjc and myself as to how we each do things.
...A topic which we shamelessly hijacked. 'Automatic Magic Number'. NablaQuant had a clever way of distinguishing between charts for the same symbol and timeframe, but it doesn't work across restarts.
...A topic which we shamelessly hijacked. 'Automatic Magic Number'. NablaQuant had a clever way of distinguishing between charts for the same symbol and timeframe, but it doesn't work across restarts.
OK, thanks for your help. I don't think there is the ideal solution, but some work arounds which will do.