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
Good afternoon,
I am trying to run the first script from the book, which generates a csv file.
It is called initial_data.mq5.
When running the script on the first step:
If(CopyClose(_Symbol, PERIOD_M5, Start, End, close) <= 0 ||
CopyOpen(_Symbol, PERIOD_M5, Start, End, open) <= 0 ||
CopyHigh(_Symbol, PERIOD_M5, Start, End, high) <= 0 ||
CopyLow(_Symbol, PERIOD_M5, Start, End, low) <= 0)
return;
CopyClose is always equal to -1
and the script crashes, re-runs do not help and as I read in the comments
this is a normal situation and means that there is no data from the server.
However, I do not fully understand how the path to the data files is written in this script.
It is written in the MQL5 documentation:
For example, EURUSD symbol data from the MetaQuotes-Demo trade server will be located in theterminal_directory\bases\MetaQuotes-Demo\history\EURUSD\folder.
And I do have files with .hcc resolution and a subdirectory \cache with files like H4.hc on it
But in the script initial_data.mq5, there is only one place where the path is written.
PrintFormat("Correlation coefficients saved to file %s\\\\Files\\\\%s",
TerminalInfoString(TERMINAL_DATA_PATH), FileName);
I output TERMINAL_DATA_PATH
2024.06.16 22:53:39.982 path (EURUSD,M5) dataPath =C:\Users\HPAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075
What should I do to correctly specify the path to these files or should it automatically hook them from the terminal directory according to MQL5 logic?
How to download data to a csv file?
Forum on trading, automated trading systems and testing trading strategies
Any questions of beginners on MQL4 and MQL5, help and discussion on algorithms and codes
Aleksey Vyazmikin, 2024.06.18 06:28 pm
FileOpenParameters
open_flags
[in] combination of flags defining the mode of working with the file. The flags are defined as follows:
FILE_READ file opens for reading
FILE_WRITEfile opens for writing
FILE_BINbinary read-write mode (no conversion from and to string)
FILE_CSVfile of type csv (all written elements are converted to strings of the appropriate type, unicode or ansi, and separated by a delimiter)
FILE_TXTplain text file (same csv, but separator is not taken into account)
FILE_ANSIstrings of ANSI type (single-byte characters)
FILE_UNICODEstrings of UNICODE type (double-byte characters)
FILE_SHARE_READshared read access by several programs
FILE_SHARE_WRITEshared write access by several programs
FILE_COMMONfile location in the common folder of all client terminals \Terminal\Common\Files.
Note
For security reasons, work with files is strictly controlled in MQL5 language. Files, which are used for file operations using MQL5 language tools, cannot be located outside the file "sandbox".
If a file needs to be read in a certain encoding (the codepage parameter with the codepage value is specified), the FILE_ANSI flag must be set. Without specifying the FILE_ANSI flag, the text file will be read in Unicode without any conversion.
Thefile is opened in the folder of the client terminal in the MQL5\Files subfolder (or the testing agent_agent\MQL5\Files directory in case of testing). If FILE_COMMON is specified among the flags, the file is opened in the common folder of all client terminals \Terminal\Common\Files.
You can open "named channels" according to the following rules:
In the above lines, the special backslash character '\' is used, so when writing the name in an MQL5 programme, '\' should be doubled, i.e. the above example should be written in the code as "\\\\servername\\pipe\\\pipename".
For more details on working with named channels, please read the article "Communication with MetaTrader 5 via Named Channels without DLL"
Honestly, I didn't understand anything from the answer, as if a robot was writing. I know where the file to be created is written to, but it is not created.
I have a specific question, how to take data from .hcc and .hc files to write to .csv?
Running the initial_data.mq5 script from the book as a result:
CopyClose is always -1. How to fix this?
I have a suspicion that it just doesn't see these files because the path to the data files is not spelled correctly.
How do I spell the path to the data files correctly?
In my case, the data files are in the terminal_directory\bases\MetaQuotes-Demo\history\EURUSD\ folder inside the sandbox.
I've been struggling with this for a week, I've read everything, but I haven't found a solution. Please help me.
Honestly, I didn't understand anything from the answer, as if a robot was writing. I know where the file to be created is written, but it is not created.
I have a specific question, how to take data from .hcc and .hc files to write to .csv?
Running the initial_data.mq5 script from the book as a result:
CopyClose is always -1. How to fix this?
I have a suspicion that it just doesn't see these files, because the path to the data files is not spelled correctly.
How to correctly specify the path to the data files?
In my case, the data files are located in the terminal_terminal_directory\bases\MetaQuotes-Demo\history\EURUSD\ folder inside the sandbox.
I've been struggling with this for a week, I've read everything, but I haven't found a solution. Please help me.
All data are taken from the platform, the user does not care where the terminal gets them from - from what file.
The script works with the data that are reflected on the chart.
Check if there are dates on the chart for which you are requesting quotes.
All data is taken from the platform, the user does not care where the terminal gets it from - from what file.
The script works with the data reflected on the chart.
Check if there are dates on the chart for which you are requesting quotes.
Please explain what it means.
In the script there is a range
input datetime Start = D'2015.01.01.01 00:00:00'; // Period beginning
input datetime End = D'2020.12.31 23:59:00'; // Period end
on M5
Should I take the EURUSD chart on M5, scroll to 2015.01.01 and then run the script on it?
Or can I run the script on MN ? And with new ticks it goes back to the beginning?Can you please explain what that means?
In the script there is a range
input datetime Start = D'2015.01.01.01 00:00:00'; // Period beginning
input datetime End = D'2020.12.31 23:59:00'; // Period end
on M5
Should I take the EURUSD chart on M5, scroll to 2015.01.01 and then run the script on it?
Or can I run the script on MN ? And with new ticks it goes back to the beginning?Read the help on the terminal. And here's another thing.
You will find out that there is a setting of history depth through the maximum number of bars in the window. You need to reload the terminal for the changes to take effect.
Thus, it is necessary to set the maximum depth of history for all TFs at once by the smallest TF that is required for work.
It is clear that 100 bars for days and 100 bars for minutes will give the same depth in bars, but not in dates.
When you set the required value or "Unlimited" and reload the terminal, if the history is available for the required period, you can run the script on the monthly TF.
Read the terminal help. And here's another.
You will learn that there is a setting of history depth through the maximum number of bars in the window. For changes to take effect, you need to reload the terminal.
Thus, it is necessary to set the maximum depth of history for all TFs at once by the smallest TF, which is required for work.
It is clear that 100 bars for days and 100 bars for minutes will give the same depth in bars, but not in dates.
When you set the required value or "Unlimited" and reload the terminal, if the history is available for the required period, you can run the script on the monthly TF.
Thank you! It worked.
You're welcome.
Thank you Dmitry for all your efforts in this book. It is really useful.
In neuronbase.mqh you implement the ElasticNet Regularization method as below without explanation in your book.
m_cWeights.m_mMatrix -= m_cWeights.m_mMatrix * Lambda[1] + Lambda[0]
But it is different from the basic formula (+) or from the Keras source code (+) for example.
Please explain about your implementation method. Why you just use lambdas instead of the complete formula and why you multiply weights with one of them and sum with another one.