No.17: Trade splitting with two trades
Description
You can find an example for the Expert Advisor Builder on this page. If you need to familiarize yourself with the MetaTrader strategy tester and the Expert Advisor Builder, please begin with the Getting Started article.
Splitting the risk of a trade is a common practice of proper risk and money management. This example demonstrates how this is achieved by using multiple trades to react on the same signal. The long orders are opened based on signals from a MACD oscillator. Signals are only generated when the slope of the MACD signal and MACD main lines is positive. When the price changes in favor of positive trading results, a second trade is opened with the same lot size as the first one. Both trades are utilized with the same take profit and stop loss trailing method, which uses a fixed value determined by the rate of change of input parameters. In this example, multiple trades can be opened simultaneously, whereby one trade is considered the master trade and one as the slave trade.Please note that this is not a plug-and-play trading strategy. A trading strategy needs suitable adjustments, fine-tuning to the timeframe and symbol, and thorough backward and forward testing. Therefore, providing fully working trading strategies as read-to-use examples is impossible. However, this example could serve as a foundation for your trading strategy.
Reset of inputs
Locate the Expert Advisor Builder application in the dropdown menu of the strategy tester settings under FEA Trading\MT4\Expert Advisor Builder 2.0 if you're using a MetaTrader 4 instance or FEA Trading\MT5\Expert Advisor Builder 2.0 if you're using a MetaTrader 5 instance. You can replicate the entire example in minutes by following the steps outlined in this article. To begin, kindly reset the strategy tester input as indicated.
The default input parameters of the Expert Advisor Builder are designed to be highly functional. This implies that only some parameters must be adjusted when creating a new strategy. As a result, even with minimal reconfiguration, the output strategy can be significantly different.
Inputs configuration
Most examples can be executed in any timeframe and on any symbol. However, please set EURUSD as the symbol to be tested, M15 as the timeframe, select Open prices only (MT4) or 1 minute OHLC (MT5) as the model, and the previous four weeks as the test period. Finally, enable the visual testing mode.
Refer to the table below to set up the input parameters for the Expert Advisor Builder.
Input variable within MetaTrader (Identifier in SET file) | Example value | User manual chapters |
---|---|---|
> (OUF) Idea output description (max 63 characters) (IN_strOufIdeaOutputDescription) | No.17: Trade splitting with two trades | Output Folder |
> (ISL) Selection (IN_enmIslSelection) | RATE OF CHANGE | Initial Stop Loss |
> (ISL) Rate of change (min value) (IN_dIslRateOfChange) | 0.002 | |
> (SLT) A Type (IN_enmSltAType) | FIX | Stop Loss Trailing |
> (TSP) A open volume (0 -> OFF) (IN_nTspAOpenVolume) | 100 | Trade Splitting |
> (TSP) A open position (IN_nTspAOpenPosition) | 150 | |
> (OSA) CONF, Signal in use (IN_enmOsaSignalInUse) | ON | Configuration 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 |
Confirm the inputs by pressing OK, and finally, start the test run with Start.
Chart example and SET file download
The underlying algorithm is highly optimized for execution speed. Generally, it only takes a few minutes until the entire test period is simulated. At the end, you will see a chart similar to the following.
To reproduce the chart from this example, you can download and use the SET file package eab_example_17_v_2_0.set.