Skip to main content
Version: 2.0

Condition

Folder path and data organization

The Custom Expert Advisor manages its file and folder inputs within two distinct folders: the live folder for the live variant and the tester folder for the tester variant. You can access these folders via the Windows start menu or through a shortcut configured on your Windows desktop, as shown in the image below.

File Input, Condition, Application folder on desktop and start menu.png

Please refer to the appropriate input folder corresponding to your variant.

Tester variant

As you navigate further down the file structure in the tester folder, you'll encounter the condition text file. The configuration folder is utilized to specify the available trading modules. Meanwhile, the system text file determines which trading modules will be actively used. The third step in this process involves using the condition text file to specify the trading state for each module. Please note that only those trading modules with enabled conditions can execute trades. The folder structure begins with the tester folder and is illustrated below. This structure must include the condition text file as indicated.

File Input, Condition, Folder path and data organization for tester variant.png

Alternatively, you can access the tester Condition input folder by inputting the designated path into your Windows folder browser.

%AppData%\MetaQuotes\Terminal\Common\Files\FEA Trading Tester Data\Custom Expert Advisor Tester 2.0\default\Condition

Live variant

As you navigate further down the file structure in the live folder, you'll encounter the condition text file. The configuration folder is utilized to specify the available trading modules. Meanwhile, the system text file determines which trading modules will be actively used. The third step in this process involves using the condition text file to specify the trading state for each module. Please note that only those trading modules with enabled conditions can execute trades. The folder structure begins with the live folder and is illustrated below. This structure must include the condition text file as indicated.

File Input, Condition, Folder path and data organization for live variant.png

Alternatively, you can access the live Condition input folder by inputting the designated path into your Windows folder browser:

%AppData%\MetaQuotes\Terminal\Common\Files\FEA Trading Live Data\<META_TRADER_INSTANCE_NAME>\Custom Expert Advisor Live 2.0\default\Condition

<META_TRADER_INSTANCE_NAME> shall be your MetaTrader instance name, for example, MetaTrader 4 IC Markets.

Usage

The condition text file, like the system text file, can be modified using any text editor. Each module in the system text file must have a corresponding entry in the condition text file that defines its trading state. The file can contain additional entries, even for trading modules not included in the system text file. However, all entries in the system text file must also be listed in the condition text file. The Custom Expert Advisor will issue a warning in the MetaTrader's experts tab if this requirement is unmet.

The code block below contains a condition text file with two entries starting from line number 2. Line number 1 is included for your convenience.

/<Input folder>/<Condition>/Condition.txt
Please ensure data is in format <MODULE_NAME> <MODULE_STATE> where MODULE_STATE can be ENABLED','DISABLED_WITHOUT_CLOSING or DISABLED_WITH_CLOSING for each module!
EAM_I1 ENABLED
EAM_I2 ENABLED

There are three possible trading conditions:

  • ENABLED: The module is fully enabled and can open new trades.
  • DISABLED_WITHOUT_CLOSING: The module is disabled, but any open trades will not be closed when the condition changes. Open trades will be closed at their defined stop loss or take profit levels.
  • DISABLED_WITH_CLOSING: The module is disabled, and any open trades will be closed when the condition changes, regardless of the current profit.

To add a new trading module, add a line with two identifiers: <MODULE_NAME> <MODULE_STATE>. The module name must match strictly as used in the system text file, and the module state must be one of the three options listed above. The file extension for the SET files is not required.

The following code block shows how to turn off trading modules EAM_I1 and EAM_I2 and enable EAM_I3 and EAM_I4.

/<Input folder>/<Condition>/Condition.txt
Please ensure data is in format <MODULE_NAME> <MODULE_STATE> where MODULE_STATE can be ENABLED','DISABLED_WITHOUT_CLOSING or DISABLED_WITH_CLOSING for each module!
EAM_I1 DISABLED_WITHOUT_CLOSING
EAM_I2 DISABLED_WITHOUT_CLOSING
EAM_I3 ENABLED
EAM_I4 ENABLED

In this example, the modules EAM_I1 and EAM_I2 were turned off, but any open trades remained open until they were closed by their stop loss or take profit levels. After some time, all trades related to EAM_I1 and EAM_I2 were finally closed.

/<Input folder>/<Condition>/Condition.txt
Please ensure data is in format <MODULE_NAME> <MODULE_STATE> where MODULE_STATE can be ENABLED','DISABLED_WITHOUT_CLOSING or DISABLED_WITH_CLOSING for each module!
EAM_I3 ENABLED
EAM_I4 ENABLED

If you remove a trading module from the system text file while trades are actively opened, the Custom Expert Advisor will stop managing its properties, such as stop loss trailing or risk splitting. Therefore, it is highly recommended to have a routine to properly define the end of the trades before removing the set file from the system text file. To do so, please use the condition text file input.