- Divergence signal description
- Strategy implementation in the automatic trading robot Keep Calm EA
- Input parameters in the Keep Calm trading robot
- Optimization results on history for 20 years
- What are the most important parameters when optimizing the Keep Calm EA
- Buy a robot for trading on the forex exchange in the MT4 terminal
Introduction . A trading robot or a trading expert advisor (abbr. EA) is an automated program that independently opens, closes or accompanies transactions on a trading account using a specific algorithm that implements the strategy (the author’s idea). The client’s task is to enable or disable the robot based on the market situation, as well as to optimize the parameters for trading instruments. For example, indicator parameters, lot volume, risk or money management, backtesting.
In my opinion, the best trading strategy for forex and stock market is based on divergence signals. Because they show very clear entry and exit points – trend reversals. This is a leading strategy, and not lagging as is usually obtained based on indicators.
The idea of this EA is not new. Her trading strategy is well described in the book by professional trader A. Elder “Two Roads Diverged: Trading Divergences” I developed the idea further and wrote an author’s trading strategy suitable for forex and not only. To do this, I chose 3 indicators, OsMA (with basic parameters 12,26,9) and Price deviation MA (with parameter 40) I use to receive a signal for a reversal (divergence / convergence) and ADX (with parameter 45) as a filter, to filter out the most likely losing signals.
This strategy is counter-trend. The algorithm tries to find a trend reversal point, therefore, it gives a large percentage of trades with a short stop loss, but the profit potential can exceed the stop by ten or more times. In this regard, it is important to understand that the higher the ratio of take profit to stop loss, the more likely a longer series of losses is. Therefore, you need to correctly choose a small risk per trade, no more than 5%.
Let’s look at examples of buy and sell deals. The picture shows a sell trade for Brent crude oil (BRN) on a 4 hour timeframe. A peak is seen in the area of the first black line on the Price deviation MA and OsMA indicators, which is smaller in the area of area 2 of the second black line. At the same time, the opposite situation is noticeable with the price. The divergence of the price with the value of the indicators (turquoise inclined lines) is our signal to open a deal. In order to assess the strength of the trend, it is customary to use the ADH indicator and its main line. Therefore, when it is less than 19, I open a trade.
A buy deal on the AEX (FTI) Dutch stock index on a 30 minute timeframe looks similar. A turquoise line connecting the tops of indicators and prices, they converge. The convergence of prices and technical indicators is called convergence.
The main feature of an expert advisor is the consistency and stability of the strategy, which is confirmed by 20 years of history tests. A feature is multicurrency (the ability to trade on many brands) and a variety of timeframes (intraday and medium-term trading). The Expert Advisor is suitable for any instrument, while it runs 15-20 instruments on one chart at once and preferred timeframes such as hourly or daily charts. The disadvantage is counter-trend and manual transaction support to maximize profits.
The following princes are put into operation of the trading robot algorithm. When a signal is generated, a prerequisite is the crossing of the 0 line of the OsMA indicator between the black lines (see the deals above). Only the first signal (the second top) is used, if later another top is formed, the robot will not open a deal. The robot always opens trades with stop loss and take profit. The robot does not use volume doubling, martingale or other ways to “win back”. To support transactions, it is possible to use the price channel indicator. And now in more detail what each parameter is responsible for.
1. «symbols»=”EURUSD,GBPUSD”. As a rule, the line is entered in capital letters, separated by commas, the ticks of the instruments on which the robot is planned to trade.
2. «time_frame»=”15,30,60,1440″. The numbers of timeframes are entered into the string separated by commas. Accepted values can be 1,5,15,30,60,240,1440,10080 minutes. Which corresponds to the timeframes M1, M5, M15, M30, H1, H4, etc.;
3. «K_TP»=11, how many times the take profit is greater than the ATR; Take profit is measured using the indicator;
4. «K_SL»=1, stop loss value in the ATR; Stop loss is measured through the indicator.
5. «Risk»=1, risk value in% of the deposit per 1 trade;
6. «ATR»=35, parameter used for the ATR indicator, which determines stop loss and take profit;
7. «N_Atr»=100, the period for which the maximum value of the ATR indicator is selected;
8. «ADX»=45, parameter used for the ADX indicator,
9. «ADX_kef»=19, signal level for the main line for the ADX indicator, which filters signals. If you put the value above 100, then deals will be opened ignoring this filter;
10. «MA_dev»=40, moving average values for the Price deviation MA indicator;
11. «N_period»=70, the minimum signal search frequency. The search for the maximum or minimum price occurs for the last N_period candles;
12. «Alert_Min_TF»=30, value in minutes, how often the EA monitors the market (stores signals in memory); This value must be at least the minimum timeframe;
13. «Alert_Min_Open»=5, the value in minutes, how often the advisor tries to open an existing signal (for example, low liquidity or no quotes are received, more than 1 attempt is needed);
14. «Soprov_on»=true, turns on disables tracking (movement of stop loss) of deals based on the PriceChenel indicator;
15. «Alert_Min_Sopr»=30, value in minutes, checks each time if the stop loss needs to be modified; This value must be at least the minimum timeframe;
16. «PriceChenel_period»=30, value of the PriceChenel indicator;
17. «PriceChenel_start_bar»=10, the number of candles through which, after opening a deal, you can apply support.
When changing the basic parameters, you can pick up better results on history, but I gave an example of a set of parameters in which the robot did not drain the deposit on 4 tests. I recommend experimenting a little with the parameters, if you have your favorite instruments and know the volatility for them, thereby optimally adjust the value of take profit and stop loss.
The Expert Advisor was tested and optimized for the EURUSD and GBPUSD currency pairs from 01/01/2000 to 01/01/2020 with the parameters given above and in the picture. The initial deposit was $ 10,000.
In my opinion, the most important is N_period , because the higher this value, less often our extremum, for example. A period of 250 on D1 will mean that we have reached an extreme in the last 250 daily candlesticks (almost 1 year). If this value is 70 (as by default), we are looking for an extremum for the last 2.5 months, etc. Naturally, the higher this parameter, the fewer deals will be opened, but at the same time their quality will be higher. Therefore, the main thing is to maintain a balance between the quality of transactions and the total profit that we can get for a certain period of trading.
Next in importance is the Take Profit to Stop Loss ratio . The larger this ratio, the longer the drawdown will be. The higher the stop loss value, the more conservative the EA parameters.
Other indicator parameters are important, but they will not contribute as much to profitability as the above 3 parameters.
For those who liked the idea of divergence and the possibilities of an expert advisor, I recommend downloading the robot for free in the MT4 terminal and testing it using the following link.
For an experienced algotrader, this expert advisor can add variety to the portfolio by trading against the trend, thereby differentiating risks.