03.12.2020

How to test and optimize trading strategies. Manual strategy tester - which one to choose? Checking the strategy on historical data in Excel


In this article, we will show the results of testing a simple trading strategy in 3 modes: " OHLC on M1" using only Open, High, Low and Close prices of minute bars; then detailed simulation in " All ticks", and the most reliable testing in the mode " Each tick based on real ticks" using recorded ticks from history.

This will allow us to understand what quality we achieve in different modes, and show how to use the tester correctly to get quick results. The "OHLC on M1" mode allows you to get a quick evaluation test, the simulation in the "All ticks" mode gives us a good approximation to reality, and testing on real ticks gives the most accurate results, but requires a corresponding amount of time. In addition, errors in logic trading robot may affect the number of trading operations and lead to the fact that the results of testing the strategy on history depend on the selected testing mode.

What trading strategy did we test

We have created a simple range breakout trading strategy based on the latest RangeLength bars. The rules of trading in it are as follows: on a newly opened bar, the range of the highest and highest low prices for the last N bars. In the attached Expert Advisor, the RangeLength parameter is set to 20 bars by default and means the width of the window in which we build the range.

After the first break of the range up or down, the statistics of incoming ticks begin to accumulate: how many ticks turned out to be above the level of the broken range, and how many - below. As soon as the incoming ticks become greater than or equal to TicksForEnter =30, a decision is made to enter the market by current price. If the range was broken upwards, then the number of ticks above the breakout level must be greater than the number of ticks below this level. In this case, a purchase is made. To enter short position it's the other way around.

exit from open position happens in time, through BarsForExit bars. As you can see, the trading rules are simple. For clarity, they are shown in the figure:

Let's see how the results of testing this strategy change in three different tick simulation modes.

How We Tested

The trading strategy was tested on EURUSD on H1 in the first 6 months of 2016 - from 01/01/2016 to 06/30/2016. All parameters of the Expert Advisor were set to default values, because our task was to simply test the strategy in different simulation modes.


Comparison of results under different testing modes

The results of testing in different modes are summarized in a table. First of all, the difference in the number of trading operations is striking. Accordingly, all other test indicators are also different. At the same time, testing in the "OHLC on M1" mode took 1.57 seconds, which is 23 times faster than in the "All ticks" mode. Such a difference will be of great importance when optimizing the input parameters of the trading system.

In turn, the "Every tick based on real ticks" mode was even more time-consuming - 74 seconds versus 36.7 seconds in the "All ticks" mode. This is easily explained by the fact that when using real ticks, more than 34 million ticks were simulated, which is almost 2 times more than in the "All ticks" mode. Thus, the more ticks we use when testing, the more time is required for one pass in the strategy tester.

Parameter
OHLC on M1
All ticks
Every tick
based on real
Tikov
731 466
18 983 485
34 099 141
Net profit
169.46 -466.81
-97.24
Trades
96
158 156
Deals
192
316 312
Equity drawdown (%)
311.35 (3.38%)
940.18 (9.29%)
625.79 (6.07%)
Balance drawdown281.25 (3.04%)
882.58 (8.76)
591.99 (5.76%)
Profitable trades (%)
50 (52.08%) 82 (51.90%) 73 (46.79%)
Average continuous winning streak
2
2
2
Testing time, including tick generation time
1.6 seconds
36.7 seconds
74 seconds (1 minute 14 seconds)

We have collected test reports in different simulation modes in the form of animated GIFs so that you can see the difference in statistics.


Accordingly, the balance charts and own funds also have differences. However, it is clear that this simple strategy does not look attractive - a period of growth is replaced by a period of decline, and the charts of each test look like a chain of chances. You cannot trade using such a system, the result will be similar to tossing a coin.



Trading systems dependent on the arrival of ticks

The demonstrated trading system depends very much on the modeling method - on the number of incoming ticks and the order in which they are received. When testing in the "OHLC on M1" mode, we simulate the fewest ticks, and they may not always be enough to enter the market. The modes "All ticks" and "Each tick based on real ticks" can have a completely different order of ticks. When modeling "Every tick" we can get a monotonically increasing or monotonically decreasing sequence of ticks, which practically guarantees entry into the market when the range is broken. When testing in the "Each tick based on real ticks" mode, the recorded history of ticks is used, and there the dynamics of price changes can be completely unexpected.

As a result, even at the beginning of the testing interval, we see that both the entry and exit levels themselves differ on the charts, and some trades are skipped.



Four tick generation modes

Strategy Tester in terminal MetaTrader 5 allows you to check trading strategies in four tick simulation modes, they are described in the MetaTrader 5 Testing Basics article. The fastest and roughest is the " Only opening prices", at which trading operations can only be made at the opening of a new bar. In this mode, the EA is not allowed to perform any actions inside the bar, and it is well suited for testing strategies that do not take into account how the price develops inside the bar.

Next in terms of modeling accuracy is the mode " OHLC on M1", at which the Open, High, Low and Close prices of each minute bar included in the tested history range are simulated. Thus, when testing on the H1 timeframe for an hour, the Expert Advisor will be called 240 times: on each of the 60 minute bars, the OnTick() handler will be called 4 times - once for each OHLC price.With this modeling, you can already use Trailing Stop, view the price development on other timeframes and indicators, if necessary.For example, test strategies like " 3 Elder Screens".

If you need a completely reliable reconstruction of history in the strategy tester, then use the " All ticks based on real ticks". In this mode, the tester independently downloads the recorded real ticks from the broker's trading server and builds the price development based on them. For history segments without real ticks, the tester models the price in the same way as in the " All ticks". Thus, if the broker has the entire recorded history for the required symbols, you can test the real historical data without artificial modeling. However, the payoff for such tick-by-tick accuracy will be a significant increase in testing time, as shown in the table with the results of comparing the three modes .

Start system development with "OHLC on M1" mode

As you can see, it is impossible to win in everything at the same time - if we want to reduce time and quickly test a trading idea, then we lose accuracy in simple simulation modes. If for testing it is necessary to ensure the accuracy of entry prices and the consistency trading signals, then you need to use more accurate modes that require more time.

Before you start testing a trading strategy, you must be clearly aware that the chosen simulation mode determines the accuracy of the results and the amount of time spent on obtaining them. If you need to quickly evaluate and test your trading strategy, use the "OHLC on M1" mode. In it, you can quickly assess the potential of the trading system.

The next stage is debugging and the "Every tick" mode

If the preliminary results turned out to be satisfactory, then you can continue fine-tuning and analyzing the trading system in more accurate simulation modes. Here, debugging the strategy in testing mode will come to the rescue - you can set breakpoints and check the state of variables and the fulfillment of the conditions laid down in the EA. Here you can expect unpleasant surprises if you forgot to provide for some of the nuances of your system.

Testing accuracy vs. speed

As can be seen from the results of testing the described trading system in three modes, a trader can always and should choose the tick simulation mode that suits his trading strategy. If you are testing the system on the daily timeframe, then the " Only opening prices"- high testing speed will not be at the expense of the quality of the results.

If you are writing a scalping or arbitrage strategy, or your strategy is based on real-time calculations of indices or synthetic indicators, then the "" mode is required. Testing will take much more time, but you will get the results as close to reality as possible. True, we must not forget that history never repeats itself, and therefore, even in this mode, input parameters ideally selected with the help of optimization do not guarantee success when launching the robot on a real account.

Between these two extremes are " OHLC on M1" and " All ticks", which are faster than " Each tick based on real ticks", but give less testing accuracy. In general view we can formulate a law describing the time and accuracy of testing:

The faster the test passes, the lower the accuracy of trading simulation. The more detailed and accurate the price development is modeled on history, the more time is required for testing.

Trading servers have been accumulating real tick history for many years, and the strategy tester in MetaTrader 5 in the "Each tick based on real ticks" mode will download all the necessary history automatically. But the more reliable the testing is, the more resources it requires. Therefore, choose a balance between accuracy and speed.

Not all strategies require detailed modeling in the early stages of development. Right choice testing mode will help you save time and weed out more wrong strategies!

And only after solving the main task - creating a profitable automatic trading system - you can optimize on real ticks. At this stage, you will already need the power of a distributed computing network.

Hello fellow traders! Today's article will be of interest to both novice traders and professionals! As you know, in the MT4 trading terminal there is a so-called , designed for testing automatic trading systems, that is . But what if you have a manual strategy, how to test it? Of course, you can test the strategy on history, but this is too long and inconvenient. And then, when you already know how the price will behave on history, you begin to unconsciously juggle the results of the strategy, they say, here I would break even or close the deal earlier, etc. If you want to objectively assess your trading capabilities or the profitability of the strategy , then you will need a Forex trading simulator. This is a special simulator that will help you get two years of trading experience in just one week. Today we will look at various programs for testing strategies, compare their capabilities, as well as their advantages and disadvantages.

What is a Forex Strategy Tester?

Tester manual strategies is a special program that simulates Forex trading. Outwardly, it resembles trading terminal MetaTrader 4. In the strategy tester, you can download currency pair quotes, select a trading period and timeframe, set indicators and templates, open deals, including pending orders, place stop losses and take profits - in general, do everything that is done in a regular trading terminal. For example, you can set the trade date to before and see if your strategy can withstand price fluctuations during the UK referendum. Or you have downloaded it from our website and want to check its effectiveness - the strategy tester will also help with this. And if you are still a beginner, then the strategy tester will help you gain invaluable Forex trading experience in a few days. Unlike a demo account, where trading is carried out in real mode, in the strategy tester you can speed up the time and test the strategy in a few days. This is especially true on weekends when the market is closed. With the help of the strategy tester, you can also work on your emotions and hone your trading skills.

1. Forex Tester 3

Forex Tester is the most popular strategy testing software. With it, you can quickly test a manual strategy or an Expert Advisor, saving time and money.

Benefits of Forex Tester 3


Disadvantages of Forex Tester 3

The only drawback of Forex Tester is that it is paid. However, you have the opportunity to evaluate its capabilities for free on a demo version. But it has its limitations:

  • testing on a time interval of no more than 1 month of historical data;
  • continuous testing cannot last more than 1 hour (at the end, you need to start testing again);
  • you can not save projects, templates and test results;
  • other possibilities are the same as in full version programs.

To date, Forex Tester 3 is the most realistic and functional trading simulator. Below we will consider its free counterparts that have a similar principle of operation, but narrower functionality.

See also what are the advantages of trading on.

2. Simple Forex Tester

Simple Forex Tester is a free strategy tester that you can download at the end of the review. Its main advantage is that strategies are tested in the familiar MetaTrader 4 trading terminal, and there is no need to get used to the interface of new programs. Before you start testing, you need to download Simple Forex Tester. In the archive you will find two folders. The contents of the first folder must be copied to the root directory with the trading terminal, that is, to where you installed your MT4.

The contents of the second folder must be copied through the Trading Terminal Data Directory, as we usually add Expert Advisors and indicators.

After that, you will need to restart the trading terminal and you can start testing. To do this, you need to click on the "Strategy Tester" icon, which we use to test Expert Advisors. In the list of Expert Advisors, select SimpleFXTester_v2.ex4, and then everything as usual - select currency pair, timeframe, testing model, set the testing date and check the box next to Visualization, and also move the testing speed slider to the extreme right position. Then click on Start.

After a while, this window will appear.

Click OK and Simple Forex Tester will start.

After that, all strategy testing will be managed through this program. Here you can start testing and pause it, adjust the testing speed by clicking on Place New Order, open new trades (including pending orders), set stop loss and take profit, start a trailing stop, and modify orders and close positions.

In the trading terminal, you can watch the price and, when you think a signal has appeared, pause testing in the Simple Forex Tester window and open a deal. Also on the chart, you can follow the statistics of the tested strategy, what is your balance, how many orders were opened and closed, and what is the current profit. If desired, statistics can be disabled in the program settings.

But the most important thing is that you can install any indicator or template on the chart, that is, test any strategy. Here, for example, we have set the strategy template.

Benefits of Simple Forex Tester

  • The familiar interface of the program built into the MT4 trading terminal;
  • The strategy tester is completely free;
  • You can test any indicators and strategy templates.

Disadvantages of Simple Forex Tester

  • Minimum functionality;
  • You cannot test a multi-currency strategy (Forex Tester 3 has this feature);
  • Low testing speed (not enough Turbo mode);
  • There may be problems with downloading quotes (it may be necessary to import quotes from other sources);
  • The program often freezes and crashes, you have to start testing from the beginning;
  • The program has no technical support, there have been no updates for over 5 years and probably there will be no more.

Simple Forex Tester has three undeniable advantages - it's simplicity, free of charge and the ability to work with any indicators. It is great for beginners who are just getting acquainted with the Forex market. Otherwise, the program has many bugs and minimal functionality, so we cannot recommend it to professional traders.

conclusions

Thus, the strategy tester is an excellent tool for gaining Forex trading skills, as well as testing strategies. Which program to choose for testing strategies is up to you. If you are still a beginner, you can start with Simple Forex Tester, it is simple and free. Professional traders we recommend using a simulator Forex trading Tester 3. The money spent on its acquisition will very soon pay off with saved deposits. In addition, with the strategy tester, you can forget about demo accounts and wasted time forever. Profitable trading to you!

Before trading with real money, you should make sure that the chosen strategy is capable of consistently making a profit.

This article examines three strategies and examines their effectiveness over the past 10-18 years. It's perfect different strategies, so any trader will be able to find something interesting in them and use it in their trading.

The ideas presented here are not complete, but can serve as a good starting point for.

Gapdown trading strategy

Sometimes you can see how strong stocks, which are leaders in their sector or even the market as a whole, collapse by more than 10% overnight, so that within the next trading session back to about the original level.

This happened to Netflix (NFLX), which released the report on July 16 after the market closed.

The company showed a slower growth in the influx of new subscribers compared to investors' expectations.

On July 16, Netflix stock ended the day above its 50-day moving average at $400.48. However, the very next morning it was trading at $344, down 14%. Ultimately, by the close of the day, the price reached $379, having almost completely won back the losses.

Historical analysis

Since 2000, the S&P 500 has closed above its 50-day moving average 536 times with enough volume to open more than 10% lower the next morning.

The analysis shows that if, after each such drop, we opened a long position and closed it at the close of the same day, then such transactions would be successful in 47% of cases, and the average profit would be 0.43% (excluding commissions).

Here are some results, as well as the balance curve reflecting the dynamics of the results over time:

  • Number of transactions: 536
  • Average profit/loss (P/L) per trade: 0.43%
  • Risk Adjusted Return (RAR): 123.34%
  • Percentage of profitable trades: 47.95%
  • Wed profit: 5.83%
  • Wed . loss: -4.54%
  • Profit ratio: 1.21


As you can see, over the past 18 years, this strategy has shown quite high volatility, so it would be difficult for most traders to use it.

Although the trade statistics are quite decent, the balance curve shows that this system has been performing poorly since 2010. And this despite the fact that the commission was not taken into account.

To create a decent trading system based on the purchase of S&P 500 shares after an overnight drop of more than 10% with an exit at the close of the day, more work needs to be done.

Mean reversion trading strategy

This strategy can be used in conjunction with the trend-following strategy for microcap stocks in the Russell Microcap Index.

The complexity of applying the mean reversion principle to such stocks lies in the fact that trading volumes in such securities are low and the news flow on them is scarce. This leads to the fact that they can simply be in a state of "drift" for a long time. With that in mind, building a good trading strategy needs some kind of catalyst to avoid getting into stocks that are going nowhere.

The idea of ​​this strategy is based on the search for a new low, and a surge in daily turnover (number of shares x closing price) serves as a potential catalyst for a rapid price increase. Thus, you need to find the stock that formed a new Low, in which on the next bar suddenly appearsand the price starts to rise.

The complete set of rules looks like this:

Purchase:

  • Yesterday's Closing< минимальная цена закрытия за 50 дней
  • And today's turnover > $250,000
  • And today's turnover is > 2 standard deviations above the 20-day moving average
  • AND IBS > 0.2
  • And today's closing price is between $0.5 and $20

Sale:

  • Highest closing price in the last 5 bars
  • OR in 10 days

Deal example

The figure shows an example of such a transaction for the OVID stock:


Here you can see that on August 10, 2017, OVID forms a new Low 50 days. This is followed by a surge in volume on August 11, and IBS is 0.72.

Thus, you can enter a long trade at the open of the next day (green arrow). After 7 days, the price went to High 5 bars, so the trade is closed at the open of the next day (red arrow). The profit was 32.53% (excluding commissions).

Backtesting for all stocks from the Russell Microcap Index for the period 8/2008 to 1/2018 yielded the following results:

(The results include a commission of 0.2% per trade. Positions are fixed at $250. All entries and exits were made at the opening of the next trading day. Earlier periods were not tested).

  • Number of transactions: 6052
  • Average profit/loss (P/L) per trade: 1.02%
  • Wed hold duration, bars: 6.04
  • Risk adjusted return: 51.13%
  • Percentage of profitable trades: 53.72%
  • Wed . profit: 7.35%
  • Wed . loss: -6.33%
  • Profit ratio: 1.35


As you can see, this set of rules provides pretty good results on a very wide sample of trades for cheap stocks. The balance curve is smooth.

These are promising results, therefore, based on these rules, it is worth developing a full-fledged trading system with a realistic portfolio size, stock rating and position size calculation.

Pullback trading strategy

Pullback trading is widely used for stocks. It involves buying when a short-term pullback occurs during a long-term trend. However, if the stock is not volatile enough, such a trade ties up significant capital.

Therefore, it is interesting to explore how such a system will behave in the futures market, where the possibilities of access to borrowed capital (leverage) are much higher.

The rules for this strategy are very simple:

Purchase:

  • Closing price > 200-day MA
  • And closing price< 10-дневной СС

Sale:

  • Closing price > 10-day MA
  • OR stop loss 10%

Here are the results of testing on the history of some futures instruments:


As you can see, stock futures (S&P 500 E-Mini and Dow Jones E-Mini) showed stable results. The results for US Treasuries (US Two Year and US Ten Year) were also good. And on gold (Gold mini) and oil (Oil), the system worked poorly.

These results are based on trading only one contract and no. A fee of $10 one way is included.

As you might expect, these results indicate that this strategy works best in a bull market. Therefore, it is recommended to use some kind of market direction filter with it. In conditions bull market such a strategy can be very profitable. In any case, it is worth doing some more forward testing.

Supplementing the strategy of trading on pullbacks of the short component

It is also advisable to supplement the above strategy of trading on pullbacks with short trades. Appropriate backtesting has been done for the ES (S&P 500 E-Mini). Long trading rules remain the same, only the following appears additional rule for short trading. In fact, it is a mirror image of the rule for long trades, only looking for bullish pullbacks in a bear market.

Selling short:

  • Closing price< 200-дневной СС
  • AND Closing price > 10-day MA

Position coverage:

  • Closing price< 10-дневной СС
  • OR stop loss 10%
  • Number of transactions: 323
  • Net income: $77,445
  • Total Annual Return (CAR): 5.34%
  • Maximum drawdown (MDD): -16.45%
  • Average Profit/Loss (P/L): 3.66%
  • Profit ratio: 1.49


As you can see, the addition of the short component improved the trading results of this strategy on the ES. Net income increased from $53,901 to $77,445 over the same period of time, while the maximum drawdown remained at the same level. The balance curve looks pretty good too.

Of course, this system requires additional testing and clarification.. Nevertheless, for such a simple strategy, the first results can be considered encouraging.

Rice. 1. Optimization of the multidimensional space of algorithms for trading strategies.

Optimization of trading strategies

In the process of algorithmic trading, there is a constant need to adjust the parameters of trading strategy algorithms. The combination of all possible parameters turns into a large multidimensional space of strategy options. To get the most profitable and stable strategies, you need to explore this space and choose the optimal parameters for trading.

Most The best way the study of any set is a complete enumeration of all its elements. However, given the enormous amount of data that one has to deal with during optimization, as a rule, it is simply impossible to conduct such a study by exhaustive search. We have to apply various analytical algorithms that allow us to reduce the actual amount of research in the process of searching for extrema.

Most of these algorithms are well known: Monte Carlo method, gradient descent method, simulated annealing method, evolutionary algorithms, etc. In this case, there are various modifications of these optimization algorithms. In algorithmic trading, as a rule, there are implementations of genetic algorithms and Monte Carlo. One way or another, all these algorithms use the "magic of random numbers" or, scientifically speaking, non-linear stochastic optimization.

The classic problem with stochastic optimization algorithms is that they are not representative for small amounts of actual research and small samples. For example, Monte Carlo is not effective in a multi-extremal space; it focuses the study on the global extremum, losing sight of local, but no less interesting extrema. The algorithm does not set such tasks for itself, it just needs to find the most profitable strategy. The genetic algorithm can also go through an unsuccessful branch of mutations and stop at some local extremum, etc.
This is because these optimization algorithms at the initial stages have to make decisions on a limited amount of data in an as yet unexplored space, and important areas can easily fall out of the study. To avoid this, it is necessary to increase the data samples and the research time, and in our case, time is worth its weight in gold. It is necessary to explore the extrema of space in as much detail as possible with a minimum expenditure of time. At the same time, in the rapidly changing conditions of exchange trading, it is important to pay attention not only to profitable, but also to stable parameters of trading strategies. Stable parameters are understood as forming clusters with similar results. Profitable strategies that are outside the clusters may not be stable and lead to serious losses. In turn, the strategy from the cluster is less subject to changes in the market.

Method of stochastic cluster optimization

Taking into account the peculiarities of optimization of exchange strategies, a hybrid algorithm was developed (see) which turned out to have one pleasant side effect - it successfully identified and explored clusters. I gave the name of the resulting algorithm - "Method of stochastic cluster optimization".

The research process, therefore, the algorithm takes place in two stages:

  1. Examining the space of strategies with the removal of unprofitable and risk-prone areas
  2. Detailed study of extrema and clusters of space
Stage 1. Exploration of the strategy space with the removal of unprofitable and risk-prone areas.

In order to get rid of uncertainty in case of lack of data at the initial stages of the study, the algorithm does not set the task of finding profitable strategies, but, on the contrary, looks for the most unprofitable ones and removes them from the space along with areas bordering them with potentially high risks of losses.

Work is carried out in the following order:

  • A multidimensional space is formed from all possible parameters of the trading strategy.
  • Strategies are randomly selected from the space and tested on historical data with the specified parameters.
  • Based on the results of testing, boundary micro-regions are removed around the most unprofitable strategies. This reduces the research space and focuses on more profitable and stable areas in further iterations.
  • Iterations of testing are carried out until the strategy space has been explored to the required extent.
On Fig. Figure 2 shows how the study is shifting towards extremes, while the risk of missing small clusters with possibly good and stable parameters is minimal.
Rice. 2. The first stage of the "Stochastic Cluster Optimization" algorithm is the study of the strategy space.

Stage 2. Detailed study of clusters and extremes.

After the first stage of the study, the types of extrema become good. However, due to the peculiarities of the algorithm (many micro-regions are cut out), the space turns out to be “torn” and some extrema can not be studied in great detail. In order to fully explore all interesting clusters, the optimization algorithm starts the exploration process in exactly the opposite way. For this, all best strategies and microregions are additionally allocated around them. If unexplored strategies are found in these areas, they are additionally tested (see Fig. 3).


Rice. 3. The second stage of the "Stochastic Cluster Optimization" algorithm is a detailed study of extremes.

As a result, after the algorithm has run, all areas of space that are interesting to us are explored and clusters with profitable strategies are tested in detail. At the same time, the actual volume of research, as a rule, is no more than 25-50% of the total volume of the space of strategy options (see Fig. 4).

Rice. 4. The speed of the study of the "Stochastic Cluster Optimization" algorithm (left) is 2-4 times higher than the speed of the "Brute Force" algorithm (right).

Walk forward optimization

It would seem that the parameters have been optimized and you can start trading. However, this is not the end of the research process. The optimization process is subject to the risk of “fitting” or re-optimizing the parameters to the historical data used in the process, so you need to additionally check the results obtained. For this, the method is used Walk Forward. The essence of the method lies in the fact that the parameters of the strategies are tested on historical data different from those used in the optimization process.

To do this, the entire range of historical data is divided into samples consisting of sets:

  • IS ("In Sample")- sample used for optimization
  • OOS ("Out Of Sample")- sample used to test optimization results
Moreover, the sample ranges are formed in such a way that the OOS data follow one after the other (see Fig. 5).
Rice. 5. Scheme of Walk Forward Optimization.

To reduce the volume of research at the stages of checking the results, it is possible to immediately filter out strategies with poor performance after optimization, thereby reducing the total testing time. As a result of such a check, we will obtain objective parameters of trading strategies that are protected from overoptimization (see Fig. 6 and Fig. 7).


Rice. Fig. 6. Optimization results on the "In Sample" data.
Rice. 7. Checking the optimization results on the "Out Of Sample" data.

Analysis of results

As a rule, after checking by the Walk Forward method, most of the trading strategies no longer look as attractive as after optimization. Ideally, strategies should confirm their statistics, while extrema and clusters retain their shape and position in space.

For a comfortable analysis of the results, I visualized the multidimensional space of strategies for each parameter in the format of a heat map (see Fig. Rice. eight). The map visually evaluates the shape and size of clusters, the position of extremes, checks the influence of parameters on the effectiveness of the strategy, evaluates changes after checking for re-optimization, etc.


Rice. 8. An example of a section of space by optimized parameters and an objective function.

For integrated assessment results of Walk Forward optimization, a matrix is ​​built with all the steps and parameters that have passed the filtering. Steps are highlighted in green, at which the parameters have confirmed their indicators and in red, respectively, if they have not been confirmed. Options that perform well on in large numbers steps can be considered more suitable for trading (see Fig. 9).


Rice. 9. Matrix Walk Forward with all the results of the check on the OOS data.

If necessary, the results can be exported to third-party analysis systems for a more detailed study. For example, in R, Excel or Mathlab (see Fig. 10).


Rice. 10. Export of optimization results to Excel.

To finally make sure that the chosen parameters are correct, detailed tests of the strategies are carried out, the smoothness of the yield curve is assessed, orders are displayed on the chart, and the log of trades is studied (see Fig. 11).


Rice. 11. Detailed analysis of trading strategy parameters.

Conclusion

After optimization and all checks, we will have strategies that are potentially suitable for real trading on the Exchange.

Finally, we double-checked everything, perhaps it is already possible to start trading? In fact, we are only halfway, it's too early to send trading algorithms to battle. Next to come:

  • Test strategies on "live" data from the Exchange to confirm the indicators obtained during testing.
  • Form a portfolio of trading strategies to diversify risks. By the way, it also needs to be optimized.
  • In the process real trading periodically combine the obtained results with the test results to adjust the settings of the tester-optimizer.
But about this, perhaps, another time.
Happy trading everyone!

Tags: Add tags


First, about graphics. At the top right is the smile of volatility. At the bottom left is the profile of the current position. (the brown line is the slope of volatility, showing how volatility can change when the price changes). The rest I think is clear.

Functional. In addition to a quick position run (Start) and equity viewing (speeded up the processing procedure) and a step-by-step run (StepByStep), I added a profile and accounting for volatility changes.

How to use. (see previous blog). Just to see the result, press start. To watch step by step, check the box to the left of StepByStep. To view the position profile, click Profile. If you press StepByStep and do not want to press Profile every time, then check the box to the left of the Profile button. If you want to watch a regular (standard) profile, then uncheck Volatility. If the checkbox is checked (Volatility), then the profile is drawn taking into account the change (possible change) in volatility. (brown line on the graph).


2022
ihaednc.ru - Banks. Investment. Insurance. People's ratings. News. Reviews. Loans