A mechanical trading system for the EURUSD currency pair

P. A. Kryukov, Kemerovo

We consider a mechanical trading system for the EURUSD instrument, which implements a trading strategy, the formal basis of which is a statistical model for analyzing and predicting the dynamics of the exchange rate - an indicator of the probability of an uptrend/downtrend.

Introduction

With the development of computer technology and communications, and the advent of the Internet, it became possible to automate the decision-making process in the form of mechanical trading system (MTS) of the traderThe first of these is a system that allows us to formalize trade rules, scientifically substantiate the elements of the adopted trading strategy (TS). Research, the experience of creating predictive MTS in financial markets is practically not presented in the scientific literature.

A detailed description of the methodology of modeling the dynamics of the exchange rate under the new approach, a rigorous justification of the models are given in the author's previous work (see below). The stage of preliminary testing of the models revealed three models with different compositions of variables suitable for further research. Let us briefly consider the application of one of them to the construction of an effective TS in the Forex market and its implementation in the form of MTS in the environment MetaTrader 4 terminal (H1).

Logit is used to develop and identify the model - regression. Применение интеграла вероятности в качестве преобразования некоторой линейной функции позволяет получить результат в интервале от 0 до 1. Для доказательства адекватности модели рынка использованы стандартные статистические критерии и процедуры пакета программ SATISTICA 6.0. Для оценки качества — инструмент ROC — анализ. Структура индикатора представляет собой общий индекс, описывающий множественную классификацию сигналов от различных известных индикаторов, осцилляторов и индексов различных показателей динамики валютного курса (переменных модели), выражающий совпадение сигналов для идентификации текущего динамического поведения цены инструмента.

Model description

As a result of the preliminary analysis, the following were selected the following variables (factors). As a dynamic indicator of volatility relative to the average level at time t (yield volatility) we take linear deviation of logarithmic increments of exchange rates, to the value of which, the transformation was applied . In the model it is a variable corLinOtkle.

RSI Oscillator no lag The value of dR= (RSI(8) - MA(8)) shows upcoming trend reversals. The value of dR= (RSI(8) - MA(8)) →0 gives the oscillator crossing its average MA(8) and warns of a price reversal. In the model it is the variable RSI_100 (dR/100). The sign of the indicator value identifies the trend direction: "+" - uptrend, "-" - downtrend; the change of the sign and the value close to zero warns of a trend reversal.

To identify pivot points and trend areas, we use the average growth and growth rate of the closing price for the last n=10 bars. In the model it is the variable korCrGrowth, to which the transformation has been applied. The sign of the indicator value identifies the trend direction: "+" - uptrend, "-" - downtrend; the sign change warns of trend reversal. For an uptrend/downtrend, the average growth (closing prices for the last 10 periods) increases as the price rises/declines and decreases when the price corrects. The formulas for calculating the values of the variables are given in the author's work mentioned above.

The following probability indicator model has been developed:

,

.

The significance level p for the corresponding t-statistic for the model coefficients is taken to be p=0.00000.

At the stage of preliminary study of the model with ROC-analysis the value of the cutoff threshold p=0.5 was obtained.

Description of the strategy

The concept - trading along the trend (without cutting off the flat). Opening/closing a position - on a model signal. Stops, filters are not used. Entry to Buy - the current probability pt>p (greater than the threshold value). Entry to the sale — текущая вероятность pt<p (меньше порогового значения). Tactics used - Trade in one order: the opening of a new order on the next tick of the price after the previous one is closed, that is, a check for confirmation of the trend reversal signal.

Программирование стратегии осуществляется в редакторе MetaEditor на языке MQL4. Разработана МТС – программа-советник, способная осуществлять торговые операции в реальном режиме времени. Фрагменты кода советника приведены на рис. 1 – открытие позиции и рис. 2 – закрытие позиции на покупку по сигналу индикатора. Торговля ведется 1 –м лотом, начальный депозит — $10000, без комиссий, остальные настройки терминала – стандартные.

Strategy testing

According to Pardo, the forward window is chosen to be 6 months long. In his opinion, it is enough to conduct 12 tests and if 50% of them are profitable, the system is ready. Fourteen tests have been conducted. The entire price history (hourly data) from June 1, 2004 to July 1, 2011 is divided into 14 semiannual intervals of research.

forex expert

Fig. 1. Opening a position by the signal of the model

forex expert

Fig. 2. Closing a position by the model signal

For the criterion of TC stability achievement of annual profit not less than 15% (average value of bank deposit) on a wide range of market conditions, and ability of TS to adjust to new market conditions as a result of optimization without updating parameters (coefficients) of the market model is accepted. The criterion of the model fitness for the future is the optimal probability threshold, statistical significance of the results and acceptable performance of the TS. To test the strategy the following is used forward analysiswhich consists of two steps: optimization on a certain interval of the price history and testing (trading) on a new interval, which is not included in the optimization interval, then again optimization on the loss intervals and testing outside the optimization interval, etc. The main results of the research are as follows:

Testing on the interval of model building with the threshold value of p=0.5 confirmed the conclusions of model verification at the preliminary stage of the study and showed the workability of the strategy, although the results can not be called excellent (low value of profitability indicators).

Optimization on the first interval (01.06.2004 - 01.12.2004) allowed to improve the result (pass 11, optimal threshold p=0,01).

Forward analysis (simulated trading) on the remaining intervals from 2 to 14 with this threshold showed the profitability of the strategy on 10 intervals out of 14 (70%). This is a good result, according to Pardo, The strategy is ready for real trading.

The graph of the curve of TC capital for p=0,01 for the period 1.06.2010 - 1.07.2011 is presented in figure 3. The graph shows the unevenness of the curve, however the upward trend can be clearly seen. The unevenness can be explained by trading during the flat, possible misclassification of the dynamics exchange rate в этот период. Результаты ТС: чистая прибыль — $19848,00; прибыльность – 1,27; среднегодовая прибыль — 183,21%; количество сделок – 268, из них прибыльных – 132 (49,25%); максимальная просадка – 39,45%.

expert work statistics

Figure 3. TC capital graph

Assessment of statistical significance and performance of MTS

Results of statistical analysis of the average profit/loss per transaction: всего сделок -268; выигрышных -132 (49,25%); среднее значение выборки — 128,6851; стандартное отклонение выборки (СО) — 1313,4636; ожидаемое СО среднего — 80,2326; t-критерий (прибыль/убыток>0) — 1,603900866; степени свободы –267; вероятность (p) — 0,9452; статистическая значимость (1-p) — 0,0548.

Analysis of the confidence interval of the probability of a winning transaction as a percentage: исходные данные для функции CRITBINOM: всего сделок – 268; выигрышных сделок — 0,4925; вероятность – 0,99; результат: наименьшее значение, для которого интегральное биномиальное распределение больше или равно заданному критерию, процент прибыльных сделок – 151; верхняя 99%-ная граница — 0,563432836; нижняя 99%-ная граница — 0,421641791.

In this case the probability (significance) of the average profit/loss per trade is 0.0548, i.e. when tested on independent data the ineffective strategy would show the same profit as when tested, only in 5.48% cases. With a probability of 99% we can say that the percentage of profitable MTS trades in the future will be between 42 and 56.

Conclusions

The model has confirmed its suitability as a mathematical support for the trading strategy. The MTS is robust to random changes in the market over a wide range of market conditions (uptrend, downtrend, sideways trend) and is suitable for real trading in the future.

List of references

1. Kryukova V.V., Kryukov P.A. Statistical Forecasting of Exchange Rate // Vestn. Kuzbass State Technical University, 2010, № 6. С. 178-188.

2. Pardo R. Development, Testing and Optimization of Trading Systems for Stock Trader / Translated from English: Alpina Publisher, 2002. 221 с.

3. Kryukova V.V., Kryukov P.A. Statistical Forecasting of Exchange Rate // Vestn. Kuzbass State Technical University, 2010, № 6. С. 178-188.

4. Pardo R. Development, Testing and Optimization of Trading Systems for the Exchange Trader: Translated from English: Alpina Publisher, 2002. 221 с.

Leave a Reply

Back to top button