No.3: Hedged news 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.
A unique form of hedging involves securing a position with a counteracting trade. For instance, when planning to open a buy trade, it might be beneficial to open a sell trade simultaneously. The less favorable trade will eventually close itself out by employing an intelligent stop loss trailing method. This strategy is commonly used for trading with news. For example, when information from the Federal Reserve is released that informs about the modification of the general interest rate, it's almost certain that the market will respond with a significant price change. Still, the direction of this change is uncertain. To participate as soon as the news is released, often two trades are opened right after or even before the news is released.
Ideally, the losing trade will close quickly, and by using a trailing method without a take profit, the other trade can then benefit from a prolonged market run. This strategy only trades occasionally, but it can yield high profits when it does. Moreover, incorporating it with hedging practices minimizes the risk as much as possible.
This already highly sophisticated system is available in the following.
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, Long trading of high impact events
When each trading module is executed individually, module no. 1 only performs long operations.
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 value | User manual chapters |
---|---|---|
> (OUF) Idea output description (max 63 characters) (IN_strOufIdeaOutputDescription) | Long trading of high impact events | Output Folder |
> (ISL) Selection (IN_enmIslSelection) | RATE OF CHANGE | Initial Stop Loss |
> (SLT) A Type (IN_enmSltAType) | FIX | Stop Loss Trailing |
> (ITP) Selection (IN_enmItpSelection) | OFF | Initial Take Profit |
> (EVT) Signal in use (IN_enmEvtSignalInUse) | ON | Events |
> (EVT) Draw chart (IN_enmEvtDrawChart) | OFF | |
> (EVT) Pre signal time (IN_nEvtPreSignalTime) | 0 | |
> (EVT) Post signal time (IN_nEvtPostSignalTime) | 0 | |
> (EVT) Region ALL (IN_enmEvtRegionAll) | OFF | |
> (EVT) Region AUD (IN_enmEvtRegionAud) | OFF | |
> (EVT) Region BRL (IN_enmEvtRegionBrl) | OFF | |
> (EVT) Region CAD (IN_enmEvtRegionCad) | OFF | |
> (EVT) Region CHF (IN_enmEvtRegionChf) | OFF | |
> (EVT) Region CNY (IN_enmEvtRegionCny) | OFF | |
> (EVT) Region GBP (IN_enmEvtRegionGbp) | OFF | |
> (EVT) Region HKD (IN_enmEvtRegionHkd) | OFF | |
> (EVT) Region INR (IN_enmEvtRegionInr) | OFF | |
> (EVT) Region JPY (IN_enmEvtRegionJpy) | OFF | |
> (EVT) Region KRW (IN_enmEvtRegionKrw) | OFF | |
> (EVT) Region MXN (IN_enmEvtRegionMxn) | OFF | |
> (EVT) Region NOK (IN_enmEvtRegionNok) | OFF | |
> (EVT) Region NZD (IN_enmEvtRegionNzd) | OFF | |
> (EVT) Region SEK (IN_enmEvtRegionSek) | OFF | |
> (EVT) Region SGD (IN_enmEvtRegionSgd) | OFF | |
> (EVT) Region ZAR (IN_enmEvtRegionZar) | OFF | |
> (EVT) Importance undefined (IN_enmEvtImportanceUndefined) | OFF | |
> (EVT) Importance low (IN_enmEvtImportanceLow) | OFF | |
> (EVT) Importance moderate (IN_enmEvtImportanceModerate) | OFF | |
> (EVT) Impact undefined (IN_enmEvtImpactUndefined) | OFF |
EAM_I2.set, Short trading of high impact events
Module no. 2 only carries out short operations.
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 value | User manual chapters |
---|---|---|
> (OUF) Idea output description (max 63 characters) (IN_strOufIdeaOutputDescription) | Short trading of high impact events | Output Folder |
> (ORM) Operation (IN_enmOrmOperation) | SHORT | Order Manager |
> (ISL) Selection (IN_enmIslSelection) | RATE OF CHANGE | Initial Stop Loss |
> (SLT) A Type (IN_enmSltAType) | FIX | Stop Loss Trailing |
> (ITP) Selection (IN_enmItpSelection) | OFF | Initial Take Profit |
> (EVT) Signal in use (IN_enmEvtSignalInUse) | ON | Events |
> (EVT) Draw chart (IN_enmEvtDrawChart) | OFF | |
> (EVT) Pre signal time (IN_nEvtPreSignalTime) | 0 | |
> (EVT) Post signal time (IN_nEvtPostSignalTime) | 0 | |
> (EVT) Region ALL (IN_enmEvtRegionAll) | OFF | |
> (EVT) Region AUD (IN_enmEvtRegionAud) | OFF | |
> (EVT) Region BRL (IN_enmEvtRegionBrl) | OFF | |
> (EVT) Region CAD (IN_enmEvtRegionCad) | OFF | |
> (EVT) Region CHF (IN_enmEvtRegionChf) | OFF | |
> (EVT) Region CNY (IN_enmEvtRegionCny) | OFF | |
> (EVT) Region GBP (IN_enmEvtRegionGbp) | OFF | |
> (EVT) Region HKD (IN_enmEvtRegionHkd) | OFF | |
> (EVT) Region INR (IN_enmEvtRegionInr) | OFF | |
> (EVT) Region JPY (IN_enmEvtRegionJpy) | OFF | |
> (EVT) Region KRW (IN_enmEvtRegionKrw) | OFF | |
> (EVT) Region MXN (IN_enmEvtRegionMxn) | OFF | |
> (EVT) Region NOK (IN_enmEvtRegionNok) | OFF | |
> (EVT) Region NZD (IN_enmEvtRegionNzd) | OFF | |
> (EVT) Region SEK (IN_enmEvtRegionSek) | OFF | |
> (EVT) Region SGD (IN_enmEvtRegionSgd) | OFF | |
> (EVT) Region ZAR (IN_enmEvtRegionZar) | OFF | |
> (EVT) Importance undefined (IN_enmEvtImportanceUndefined) | OFF | |
> (EVT) Importance low (IN_enmEvtImportanceLow) | OFF | |
> (EVT) Importance moderate (IN_enmEvtImportanceModerate) | OFF | |
> (EVT) Impact undefined (IN_enmEvtImpactUndefined) | OFF |
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.
To reproduce this example, you can also download the zip package cea_example_3_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.
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.
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.