The
article describes the application of text files for storing dynamic
objects, arrays and other variables used as properties of Expert
Advisors, indicators and scripts. The files serve as a convenient
addition to the functionality of standard tools offered by MQL
languages.
Let's examine the code fragments taken from the fully operational
indicator. The indicator needs data on several currency pairs for proper
operation. So, it requests data by timer and then processes it
according to its logic (the indicator logic is of no importance for us
here). Please remember that brokers sometimes add various suffixes and
prefixes to symbol names (for example, EURUSDmay be turned into #.EURUSD.ch). This
should be taken into account, so that the EA is able to refer to other
symbols correctly. The sequence of our actions is as follows.
1. Create a text file broker.cfgwith the following content:
[PREFIX_SUFFIX],#.,.ch
2. Create a text file <indicator_name>.cfgwith the following content:
/*Number of currency pairs with the "anchor" string [CHARTNAMES] */
[CHARTCOUNT],7/*Names of the currency pairs, whose charts are used by the indicator to read the data*/
[CHARTNAMES],USDCAD,AUDCAD,NZDCAD,GBPCAD,EURCAD,CADCHF,CADJPY
/*Position of a base currency in a pair (it is CAD in this case) – first or second*/
[DIRECT],0,0,0,0,0,1,1
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
New article Using text files for storing input parameters of Expert Advisors, indicators and scripts has been published:
The article describes the application of text files for storing dynamic objects, arrays and other variables used as properties of Expert Advisors, indicators and scripts. The files serve as a convenient addition to the functionality of standard tools offered by MQL languages.
Let's examine the code fragments taken from the fully operational indicator. The indicator needs data on several currency pairs for proper operation. So, it requests data by timer and then processes it according to its logic (the indicator logic is of no importance for us here). Please remember that brokers sometimes add various suffixes and prefixes to symbol names (for example, EURUSD may be turned into #.EURUSD.ch). This should be taken into account, so that the EA is able to refer to other symbols correctly. The sequence of our actions is as follows.
1. Create a text file broker.cfg with the following content:
[PREFIX_SUFFIX],#.,.ch2. Create a text file <indicator_name>.cfg with the following content:Author: Andrei Novichkov