I just wrote my second EA and it got a bit complex. In one part it calculates and move horizontal lines based on trade losers so the next trade is based from this new position. The problem is when you have the EA running and decide to check the inputs and possibly make a change--when you close the inputs the EA starts the calculations from where it currently is and the old data are lost.
Because I'm a beginner I'm pretty hazy on arrays and using files to hold the old data in such cases. Could anyone please point me in the right direction so I can learn how to hold and reintroduce previously calculated data? Many thanks.
When settings are changed or EA is restarted, here is how MT4 proceeds:
1. EA deinit() function is run
2. EA stops its execution -- therefore, everything is discarded.
3. EA starts up again.
4. EA init() function is run
5. EA start() function now runs on every tick again
Going logically, the only way to remember previous settings or values if the program's execution is stopped is by using files or some sort of database to get these values back.
When settings are changed or EA is restarted, here is how MT4 proceeds:
1. EA deinit() function is run
2. EA stops its execution -- therefore, everything is discarded.
3. EA starts up again.
4. EA init() function is run
5. EA start() function now runs on every tick again
Going logically, the only way to remember previous settings or values if the program's execution is stopped is by using files or some sort of database to get these values back.
well..thank you for that. As I said, "I'm pretty hazy on arrays and using files to hold the old data in such cases." so I guess I wasn't clear enough. What I need is for someone to show me where I can get good information about using files in this type of case. This is so I can learn how to use them and code them into the EA.
well..thank you for that. As I said, "I'm pretty hazy on arrays and using files to hold the old data in such cases." so I guess I wasn't clear enough. What I need is for someone to show me where I can get good information about using files in this type of case. This is so I can learn how to use them and code them into the EA.
I found this by typing "files" into the search panel.
Can you tell me why you prefer not to do that?
CB
I found this by typing "files" into the search panel.
Can you tell me why you prefer not to do that?
CB
Having struggled for many days through the masses of documentaton for MQ4, I find the best way to learn is to find examples in use by those who understand what is written. I tried FileWriteArray and FileReadArray after reading that same stuff--so far I haven't been able to fully understand how to code properly to get things to work.
Since this forum has always been a source of ready help, and because I do spend a lot of time searching for phrases that may or may not be germane to my problem, I ask for help directly once I finally decide I have wasted enough time searching for things. Now, since I have satisfied your curiosity as to doing searches before asking, are you able to help?
Having struggled for many days through the masses of documentaton for MQ4, I find the best way to learn is to find examples in use by those who understand what is written. I tried FileWriteArray and FileReadArray after reading that same stuff--so far I haven't been able to fully understand how to code properly to get things to work.
Since this forum has always been a source of ready help, and because I do spend a lot of time searching for phrases that may or may not be germane to my problem, I ask for help directly once I finally decide I have wasted enough time searching for things. Now, since I have satisfied your curiosity as to doing searches before asking, are you able to help?
Yep. Not a problem. You can understand how its frustrating to get the same questions time after time.
Its actually pretty easy to write stuff away to a csv file (located in experts/files) and read it back in again.
I use it to make EAs recoverable.
What do you need to know?
CB
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I just wrote my second EA and it got a bit complex. In one part it calculates and move horizontal lines based on trade losers so the next trade is based from this new position. The problem is when you have the EA running and decide to check the inputs and possibly make a change--when you close the inputs the EA starts the calculations from where it currently is and the old data are lost.
Because I'm a beginner I'm pretty hazy on arrays and using files to hold the old data in such cases. Could anyone please point me in the right direction so I can learn how to hold and reintroduce previously calculated data? Many thanks.