
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 is the code to read from a file:
WhyFileReadString() ?
You can useFileReadArray(), then you don't need to do a loop.
WhyFileReadString() ?
Wouldn't it be better to useFileReadArray(), then there is no need to do a loop.
Rosh:
Write equity values into a file. Then build indicator by these values. However, the data file has to be moved manually because during testing the files are written to the folder Agent_name/MQL5/Files.
Only now have I realised how complicated everything is.
But manually is clearly not the solution to this issue, as we are talking about hundreds of tests.
And it would seem: in the beginning there is available data, but - oh, Miracle! - the program is designed in such a way, that there is no possibility to save them somehow and somewhere until they are extracted and used programmatically!
I am not a professional programmer, but this situation is hard to comprehend.
Huge documentation..., vast possibilities in building, it would seem, everything and everything..., memory management, OOP, and here, in fundamentally simple and critically necessary (which, I hope, I have already explained) - a deadlock.
...And yet... Question!
Is there no possibility to write in the test mode in some forced-nearly-erasable program arrays, which subsequently could be used to build an indicator?
Including the possibility to pass through a global variable a pointer to such an array?
And what is the problem of storing and transferring data between the testing stage and the time of the main work, not in terms of current implementation, but in principle?
Renat mentioned hundreds of megabytes of data, but, firstly, why should we always reload data when we can provide for such possibility only at the programmer's explicit wish and, secondly, the amount of data in terms of the task at hand is much smaller and amounts to some thousands of digits.
Once again I declare that from a user's point of view, the option of manual transfer of files during multiple testing (and the market, due to its complexity, requires multiple testing) is absolutely inconvenient and unpromising, while I'm ready to argue with anyone that the dynamics of account indicators in direct correlation with price dynamics in the testing history is one of the most important in general.
What is the question of extending the visibility in the main mode of operations of opening files in read mode to the folder of the tester's files? What would be even a hypothetical threat in this?
And what's the issue of not being able to force storage of required data between main mode and test mode in RAM?
Use dll to write and read files from arbitrary folders on disk. Simply move the file writing and reading functions to the dll and that's it.
...And yet... Question!
Is there no possibility to write in the test mode in some forced-narrow program arrays, which subsequently could be used to build an indicator?
Try to set the FILE_COMMON flag when opening the file - https://www.mql5.com/ru/docs/constants/io_constants/fileflags
Identifier
Value
Description
FILE_COMMON
4096
Location of a file in the shared folder of all client terminals. This flag is used when opening files (FileOpen()), copying files (FileCopy(), FileMove()) and verifying the existence of files (FileIsExist())
Try specifying the FILE_COMMON flag when opening a file - https://www.mql5.com/ru/docs/constants/io_constants/fileflags
Run this script and see where it writes
joo, Rash, thank you!
The shared folder option seems more... integrated.
The only thing that surprises is that when running this code, a message about failed write is displayed within the indicator, although the write itself does get done. Plus - still an open question how and when exactly it's better to write the data (separately for each tick, but it's resource-intensive, or at the very end - the whole array, but with array writing something is not quite clear yet and, besides, it's hard to understand how OnCalculated will work in this case for its extraction - in the second, it turns out the passage already after testing?)
And another question, somewhat off-topic, but on the question already touched upon yesterday.
Inserted in OnTick and in OnCalculated:
but after test completion despite the presence of objects related to opening and closing positions (arrows and lines - visible in Terminal: Charts>Objects>Objects List), the return value is 0 for some reason.It is better to write to the file as seldom as possible, so it is better to do it as an integer array. The values should be measured not more often than once a minute, otherwise there will be problems with displaying them on the chart (besides it will be unreasonably resource-intensive). That is, at the end of run. But it's also possible:
The algorithm emerges as follows:
1) Run the expert in the tester.
2) Measured the value of interest.
3) Recorded the value in the file.
4) Write true to a separate file, which means we recorded a new value.
5) Start an infinite loop, the exit condition is false in the flag file.
6) In a separate chart the script reads the file with the flag, if there is a new value, draw a risk on the chart, write false to the file.
This is roughly what visual mode of testing in the tester will look like.
Wait a bit, the contest will be over, maybe more elegant and beautiful solutions will be presented.
joo, Rash, thank you!
The shared folder option seems more... integrated.
The only surprising thing is that when running this code within the indicator it displays a failed write message, although the write itself does get done.
I don't get any of that output. Give it a try:
I don't get any of that. You should try it:
Rosh
I can't understand what is the reason, but unlike my indicators, when I start it with yours, I get a message:Now I've made a similar simple Expert Advisor, based on your code, which should write all Equity values into file (I've changed only output of all values, including zero bytes written, made variables global, and divided file opening and writing into OnInit and OnTick), but though no error is written and file is created, records and file are empty.