Free email newsletter with articles on systematic trading

 

 

Newsletter
Article Library
Videos
What's New
About Us
Site Map
Search

 

 

Adaptrade Software Newsletter Article
 

 

Reverse Engineering a Trading Strategy

by Michael R. Bryant

 

 

Reverse engineering is the process of deconstructing an object in order to duplicate it. Essentially, you start with the finished product, take it apart, figure out how it works, and base your duplicate design on what you learn.

Suppose you've seen the results for a profitable trading strategy reported online. All you know is that the strategy trades the E-mini S&P on 15 minute bars and produces the reported results over a specified time period, such as the past 10 years. You don't have access to the strategy code or even a description of the logic. Is there any way to figure out how this strategy might work?

 

It turns out there is. By working backwards from the reported performance, we can systematically try different combinations of strategy logic until we find one that matches the reported results. This doesn't guarantee we'll find the same logic used in the strategy, but we can probably find something that's pretty close.


As an example, consider the MiniMax trading system, which I developed back in 2001 for trading E-mini S&P 500 (ES) futures. MiniMax has not been updated or modified since December 2009, so any results reported since then are out-of-sample. Fig. 1 below shows the equity curve for MiniMax on the ES through early August of this year.

 

 

Figure 1. MiniMax one-contract trading results for the E-mini S&P. Trading costs: $30 per round-turn.


Since the system has held up well in recent trading, let's see if we can duplicate it based only on the reported performance results. Below I've listed some key performance metrics for the strategy, obtained from the TradeStation performance report posted on my other site at http://www.breakoutfutures.com/MiniMax/index.htm. The goal will be to find the strategy that duplicates those performance metrics as closely as possible.

 

MiniMax Strategy Performance Metrics

Metric Value
Net profit $68,463
Number of trades 260
Average trade $263
Win percentage 59%
Profit factor 1.7
Max intraday drawdown $8,500
Win/loss ratio 1.19
Average bars in trades 5.4
Maximum losing trade -$3600


To find the strategy that generates these results, we can use genetic programming (GP), which is ideally suited to this problem. By nature, GP is a search algorithm that looks for trading logic that meets the user's goals. In this case, our build goals will be matching the performance metrics listed above.

 

Using Adaptrade Builder, I set the build goals as shown below in Fig. 2.

 

Figure 2. Build goals to reverse engineer the MiniMax system.


Notice that each build metric listed in the table above is selected as a build goal (max loss metric not shown in the figure), where the "Type" is set to "Target" with a weight value of 1.0. The target values are the same as in the performance table, which means the build process will try to match the strategy results as closely as possible to the target values shown in Fig. 2. In addition to the performance metrics listed in the table above, I also added "complexity" as a build goal. Instead of setting a target for complexity, the build process is set to minimize complexity with a small weight value of 0.2. This provides a way to nudge the solution towards strategies with fewer inputs and will break ties when two strategies with different numbers of inputs have the same performance.


The other important settings in Builder are on the strategy options tab. Because MiniMax is advertised as a volatility breakout strategy, one can surmise that the entries are on stop orders. Similarly, one can conclude that the strategy employs some sort of protective (money management) stop. With that information, I checked the "Include" column for entry and protective stops in the Order Build Set table, as shown below in Fig. 3.

 

Figure 3. Selecting entry and protective stop orders to reverse engineering the MiniMax strategy.

 

Other information available about MiniMax allows one to surmise that the long and short sides are symmetric, rather than being based on completely different logic. Accordingly, I've selected the Long/Short Symmetry option.

 

MiniMax is based on daily bars of the ES with trading costs of $30 per round turn. After loading price data for the ES that matches the equity chart shown above in Fig. 1, I set the population size to 5000 with 20 generations. Since I know that MiniMax has held up well out-of-sample, my approach is to reverse engineer the strategy over the entire reported period, without saving any data for out-of-sample (OOS) testing. If successful, I could always go back and repeat the build over a shorter period, leaving some data for OOS testing as a way to verify the integrity of the build process.

 

The resulting equity curve for the top strategy is shown below in Fig. 4. Comparing this to Fig. 1 reveals a pretty close correspondence.

 

Figure 4. One-contract trading results for the E-mini S&P strategy obtained from reverse-engineering MiniMax. Trading costs: $30 per round-turn.

 

The table below compares the performance metrics between MiniMax and the reverse-engineered strategy, labeled as the MiniMax Clone. As can be seen from the table, most of the metrics are pretty close.

 

Strategy Performance Metrics Comparison

Metric MiniMax MiniMax Clone
Net profit $68,463 $66,673
Number of trades 260 248
Average trade $263 $269
Win percentage 59% 58%
Profit factor 1.7 1.63
Max intraday drawdown $8,500 $9,300
Win/loss ratio 1.19 1.18
Average bars in trades 5.4 6.2
Maximum losing trade -$3600 -$2500

 

Examples of recent trades taken by MiniMax (Fig. 5) and the MiniMax clone (Fig. 6) are shown below. Many of the trades are similar. More importantly, the trading characteristics seem to be quite similar.

 

Figure 5. Recent trades taken by MiniMax.

 

Figure 6. Recent trades taken by the MiniMax Clone strategy.

 

The MiniMax clone strategy has five inputs, which is actually fewer than MiniMax, which bodes well for future (out-of-sample) performance. I repeated the build process with the same settings over a shorter time period, leaving 20% of the data for OOS testing and adjusted the performance targets for the shorter in-sample period. Similarly close correspondence was found between MiniMax and its clone, and, more importantly, the OOS results looked good as well, which suggests that the build process is robust.

 

As the developer of MiniMax, I obviously have access to the logic for the strategy. So, did the clone identify the same logic used in MiniMax? Not quite. Interestingly, the entry conditions and exit logic in the clone are somewhat simpler than in MiniMax while producing nearly the same results. This probably shouldn't be surprising given that many indicators are highly correlated, which means that different indicators are capable of producing the same results.

 

While it may not be possible to determine the exact logic used in a trading strategy using this approach, it can nonetheless be used to develop a strategy given a set of realistic performance goals. The benefit of trying to duplicate an existing strategy is that you know the performance results are realistic, and duplicating a strategy that has a good real-time record may increase the likelihood of getting good real-time performance in the clone.

 

This process has one other interesting application. Because the reverse-engineering process is based almost solely on the performance metrics, it can be applied to a discretionary track record as well. Suppose, for example, you're a discretionary trader looking to make the switch to systematic trading. You could reverse-engineer your own track record to create a strategy that will, in principle, trade the same way you do.

 

Put your clone to work and go on vacation. Sounds good to me!

 

Mike Bryant

Adaptrade Software
 

 

*This article appeared in the September 2011 issue of the Adaptrade Software newsletter.

 

HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN INHERENT LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT ACTUALLY BEEN EXECUTED, THE RESULTS MAY HAVE UNDER- OR OVER-COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN.

 

If you'd like to be informed of new developments, news, and special offers from Adaptrade Software, please join our email list. Thank you.

 

Join Our Email List
Email:  
For Email Marketing you can trust

 

The strategy developed for this article is included as a free bonus when purchasing Adaptrade Builder.

 

Copyright 2004-2015 Adaptrade Software. All rights reserved.