New article: Using text files for storing input parameters of Expert Advisors, indicators and scripts

Back to topics list To post a new topic, please log in or register
avatar
Moderator
72392
MetaQuotes 2016.07.19 16:39
 

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],#.,.ch
2. Create a text file <indicator_name>.cfg with 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

Author: Andrei Novichkov

Back to topics list  

To add comments, please log in or register