Skip to main content
Version: 2.0

No.4: Signal generator for supportive trading

Description

You can find an example for the Custom Expert Advisor on this page. If you still need to become familiar with the MetaTrader strategy tester and the Custom Expert Advisor, please begin with the Getting Started article first.

The detailed explanation of the entire configuration process goes beyond the scope of this article. Therefore, all the necessary configuration files are also available for download. These can be found in the Chart example and profile folder download section. However, a brief explanation and the defining input parameters of each trading module in this system is provided.

Some traders prefer to open and close trades manually. Regardless of how well a trading strategy has performed in a strategy test, displaying the typical signals defined by their system on the chart can still be beneficial. This example employs the same signal generation as in example no. 1, but instead of executing trades, it merely draws a vertical line (red or green) on the chart. This practice ensures that every signal is displayed on the chart without omitted orders. This allows manual traders to discern between true and false signals personally.

Please note that this is not a plug-and-play trading system. A trading system needs suitable adjustments, fine-tuning to the timeframe and symbol, and thorough backward and forward testing. Therefore, providing fully working trading strategies as ready-to-use examples is impossible. However, this example could serve as a foundation for your systems.

Individual trading modules

This section provides an overview of how each trading module is configured and what the trading behavior looks like. It can aid in understanding the individual signals generated by each trading module. As previously mentioned, the entire trading system in this example comprises multiple trading modules. Each module operates independently but shares the same resources, ensuring that indicators or oscillators don't need to be recalculated numerous times. This approach conserves the resources required to execute the overall trading system.

EAM_I1.set, MACD - Long signals

When each trading module is executed individually, module no. 1 only illustrates long signals.

Custom expert advisor example chart 0, Signal generator for supportive trading, MACD - Long signals.png

This trading module was created with the Expert Advisor Builder. The required input parameters for this trading module are as follows.

Input variable within MetaTrader
(Identifier in SET file)
Example valueUser manual chapters
> (OUF) Idea output description (max 63 characters)
(IN_strOufIdeaOutputDescription)
MACD - Long signalsOutput Folder
> (ORM) Operation
(IN_enmOrmOperation)
LONG SIGNAL ONLYOrder Manager
> (MIS) General signal visualization
(IN_enmMisGeneralSignalVisualization)
ONVisualization
> (OSA) CONF, Signal in use
(IN_enmOsaSignalInUse)
ONConfiguration
Available Oscillators and Default Values
Example
> (OSA) COND, Relation 1 OSA1 to OSA2
(IN_enmOsaRelation1)
VALUE X CROSS VALUE X
> (OSA1) CONF, Signal in use
(IN_enmOsa1SignalInUse)
ON
> (OSA1) COND, Angle limit condition
(IN_enmOsa1AngleCondition)
GREATER LIMIT 1
> (OSA2) CONF, Signal in use
(IN_enmOsa2SignalInUse)
ON
> (OSA2) COND, Angle limit condition
(IN_enmOsa2AngleCondition)
GREATER LIMIT 1

EAM_I2.set, MACD - Short signals

Module no. 2 only draws short signals in the chart window.

Custom expert advisor example chart 2, Signal generator for supportive trading, MACD - Short signals.png

This trading module was created with the Expert Advisor Builder. The required input parameters for this trading module are as follows.

Input variable within MetaTrader
(Identifier in SET file)
Example valueUser manual chapters
> (OUF) Idea output description (max 63 characters)
(IN_strOufIdeaOutputDescription)
MACD - Short signalsOutput Folder
> (ORM) Operation
(IN_enmOrmOperation)
SHORT SIGNAL ONLYOrder Manager
> (MIS) General signal visualization
(IN_enmMisGeneralSignalVisualization)
ONVisualization
> (OSA) CONF, Signal in use
(IN_enmOsaSignalInUse)
ONConfiguration
Available Oscillators and Default Values
Example
> (OSA) COND, Relation 1 OSA1 to OSA2
(IN_enmOsaRelation1)
VALUE X CROSS VALUE X
> (OSA1) CONF, Signal in use
(IN_enmOsa1SignalInUse)
ON
> (OSA1) COND, Angle limit condition
(IN_enmOsa1AngleCondition)
SMALLER LIMIT 1
> (OSA2) CONF, Signal in use
(IN_enmOsa2SignalInUse)
ON
> (OSA2) COND, Angle limit condition
(IN_enmOsa2AngleCondition)
SMALLER LIMIT 1

Chart example and profile folder download

As a result of combining both trading modules, the chart will generate signals and trade, as shown in the following picture.

Custom expert advisor example chart 3, Signal generator for supportive trading, All modules combined.png
tip

To reproduce this example, you can also download the zip package cea_example_4_v_2_0.zip containing the entire profile folder.

In addition to the trading module SET files, the Custom Expert Advisor requires further input information, which defines the trading modules used for the trading system and the current trading stage.

The information about which trading modules are in use is defined in the System.txt file. This standard text file can be edited with any text editor. Please ensure that the existing format is maintained and lines are only added or removed. A helpful feature is that this can be done even when the Custom Expert Advisor is active.

/cea_example_4/System/System.txt
Please ensure data is in format <MODULE_NAME>.
EAM_I1
EAM_I2

Since there may be a need to turn off trading modules, a second text file-based input, which defines the trading state, is required. The code block below shows what this file (Condition.txt) looks like for the example provided in this article.

/cea_example_4/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

Please remember not to alter the basic file formatting. Like the system file, the condition file can also be adapted while the Custom Expert Advisor is active. The trading system will adjust accordingly whenever a file change is detected. This allows for modifying active trading systems while preserving previous inspector values.