Ideal Trades as Targets for Strategy Development
by Michael R. Bryant
In a recent article, I explained how to reverse engineer a trading strategy using Adaptrade Builder. The basic idea was to use the performance report for an existing trading strategy to help choose the performance targets in Builder. For example, if you know an existing strategy made $50,000 over five years in the E-mini, you can set a profit target of $50,000 in Builder when building over the same price history. This provides realistic targets for strategy development, which increases the odds of getting good results and decreases the likelihood of over-fitting.
The problem with reverse engineering an existing strategy
is that you have to have a good strategy -- or the detailed performance report
for a good strategy -- to begin with. What if you don't? This article provides
an alternative approach based on the use of ideal trades. By ideal
trades, I mean hypothetical, profitable trades of the type you'd like to see
generated by your strategy. Ideal trades are based on hindsight and are
therefore fictitious. However, they provide an estimate of the potential profit
that's possible for a given style of trading on your chosen market. As such,
they can provide useful performance targets for strategy building.
The Easy Way to Find Ideal Trades
To come up with a set of ideal trades, you could open up a price chart and start marking where you'd ideally like to enter and exit the market each day, noting whether the trade was long or short depending on whether the market was up or down that day. You could skip flat days altogether and skip any days where the market would have moved against your open trade more than you'd be comfortable with. Obviously, this would be a tedious process.
The idea behind the rules in IdealTrades is that we're trying to capture the day's trend, provided the trend is large enough (MinProfit requirement) and provided the trade doesn't move against us too much before it exits (MaxPosLoss requirement). To avoid volatility near the open and thin trading after the regular stock market close at 4:00 pm EST, the entry and exit times are specified via strategy inputs.
Examples of trades generated by the IdealTrades strategy are shown below in Fig. 1. The strategy was applied to 15 min bars of the E-mini Russell futures (day session data) with trades entering at 10:00 am and exiting at 4:00 pm EST. Trades were required to have a minimum profit of $300 after trading costs of $30 and an open trade loss of no more than -$300. The IdealTrades strategy places all trades as long trades then evaluates them as either possible long or short trades based on whether they're profitable or not as long trades. The trades on 12/23 and 12/28 were evaluated as possible short trades, whereas the trade on 12/27 was a potential long trade. Only the trade on 12/27 was recorded in the output file; the other trades did not meet either the minimum profit or maximum open loss requirements.
Figure 1. Ideal trades for the E-mini Russell futures. All trades are shown as long trades, regardless of ideal trade direction. Only trades meeting specified requirements are saved to a file.
To come up with a set of build targets from the file of trade data generated from the IdealTrades strategy, I read the data into Market System Analyzer (MSA) and examined the performance report. Most of the metrics in Builder are not suitable as targets for a set of ideal trades because they're computed from both the winning and losing trades in Builder. The ideal trade history contains only winning trades, so metrics like net profit, average trade, percent profitable, and many others would not give realistic targets.
The ones I chose to focus on were average winning trade, average bars in winning trades, and total number of trades. We have to expect that any strategy we come up with in Builder will only capture a certain percentage of the winning trades represented by the list of ideal trades. The goal is to find a strategy that trades more or less the same days as in the ideal trade list and gets as many of those trades correct as possible. Regardless of how many of the ideal trades our strategy gets right, the average of its winning trades should be roughly the same as the average win among the ideal trades; it will just be averaging over a smaller number of wins. Likewise, we want our winning trades to enter near the open and exit near the close, so they should have the same number of bars as the ideal trades. Lastly, because we want to trade on the same days as the ideal trades, we want the total number of trades to be the same.
Although I used MSA to examine the metrics of the ideal trades, the metrics I eventually chose could be easily calculated in a spreadsheet. The average winning trade is just the average of all trades since all ideal trades are wins. The average bars in winning trades was counted on the chart between the specified entry and exit bars. Likewise, the total number of trades is just the number of lines in the output file generated by the IdealTrades strategy.
The complete set of build metrics I chose is shown below in Fig. 2.
Figure 2. Build goals based on ideal trades.
Fig. 3 shows which order types were included in the build. Initially, only market entry, protective stop, and end-of-day exit orders were selected. After a few trial builds, I decided to add the stop entry and market exit order types in order to give the build algorithm more options. The exit end-of-day order type was added as a "catch-all" in case the trade didn't exit based on the time limit exit (see below).
Figure 3. Order types used to build a strategy based on ideal trades.
The strategy options selected for the build are shown below in Fig. 4. Initially, I ran the build using the symmetry option but later removed it after considering that the target market (E-mini Russell index futures) more than likely has a directional bias. I also selected the option to trade between two specified times to be consistent with the entry and exit times specified in the IdealTrades strategy. The first time, 9:45, causes the strategy to enter no earlier than the open of the following bar, which is 10:00 a.m., the target entry time. The parameter ranges were left at the default settings.
Figure 4. Strategy options for building a strategy from a list of ideal trades.
The selected build options are shown below (Fig. 5). When building based on targets, I've found that it often pays to use a larger number of generations, so I set the number of generations to 20 with a population size of 1000. In almost all cases, most of the top strategies had converged by the 20th generation, suggesting that no more than 20 generations was necessary. I also used the option to reset the build based on the out-of-sample performance. At first, I had it reset if the net profit was negative. After a few test runs, I decided to use the stricter requirement, shown below, in which the correlation coefficient must be at least 0.9 as computed on the out-of-sample results. Lastly, notice that I reduced the tree depth to 3 from the default of 4. I did this because some of the initial runs were generating strategies with too much nesting (indicators of indicators of indicators, etc.).
Figure 5. Build options for building a strategy from a list of ideal trades.
As noted above, my target market was 15 minute bars of the E-mini Russell 2000 futures (symbol TF), day session data. I initially chose five years of data, setting aside the most recent 30% for out-of-sample testing. However, I found in initial testing that the program was having difficulty extending the performance to the out-of-sample (OOS) period. This may have been due to differences in the market based on where the OOS period started or perhaps with difficulties finding effective strategy logic that worked across the entire five year history. In any case, I changed the history to a total of three years, with 30% of that reserved for OOS testing.
The reset on out-of-sample performance option caused eight resets prior to the final result. The total build process took about three hours. The equity curve for the top strategy is shown below in Fig. 6. Compared to the build targets from the set of ideal trades, the strategy created by Builder had the same number of trades (231 in-sample), an average win of $565 (vs. $904), and an average of 22 bars for winning trades (vs. 25). As expected, only a fraction (51.5%) of the trades were profitable compared to 100% of the ideal trades. Also of interest is that the maximum winning trade was $2,030 versus $2,770 for the ideal trades.
Figure 6. Back-tested equity curve for a strategy based on build targets from a set of ideal trades.
Examples of trades generated by the strategy are shown below in Fig. 7. All the trades shown in the figure enter near the open, similar to the ideal trades. The first trade is a loss. In the ideal history, this trade was a short trade winner, so the strategy generated by Builder got the direction of this trade wrong, as it did with the last trade shown below. Fortunately, the strategy exit got out of this trade early, preventing it from holding until the close, which would have generated a large loss. The middle two trades were both winners, entering near the target entry time and exiting at the target exit time of 4:00 pm, just like in the ideal strategy. In fact, both of these trades were nearly identical to the corresponding ideal trades.
Figure 7. Typical trades generated by the strategy created by Builder based on a history of ideal trades.
The idea of using a set of idealized trades to generate targets for building trading strategies seems to have merit. The strategy developed here met two of the three targets very closely. It's possible that all three targets could be met if additional build attempts were made. It remains to be seen how well the strategy will perform in real-time tracking going forward. However, the out-of-sample performance, combined with the high significance (98.7%) and the fairly linear equity curve bode well for future results.
The set of ideal trades provides an indication of the potential profit in a market. No strategy will come close to the total profit represented by the set of ideal trades. Rather, the goal is to capture as many of the ideal trades as possible while limiting the losses on ones that are missed. This was illustrated in Fig. 7, which shows the strategy capturing two out of four ideal trades while avoiding a potentially large loss on the last trade.
The IdealTrades EasyLanguage strategy developed for this article generates ideal trades of a very specific type. However, the same idea could be used to generate a set of ideal trades for almost any type of strategy you have in mind. The essential idea is to use hindsight to identify the types of trades you want, then save them to a file if they meet your requirements. Analyzing them in a spreadsheet or in a program like MSA provides the build targets.
You may find the concept of "ideal trades" familiar. In his book "Design, Testing, and Optimization of Trading Systems" (John Wiley & Sons, Inc., New York, 1992, pp. 74-75), Robert Pardo described the "perfect profit," which he defined as the sum of the absolute price differences. A trading system that generated perfect profit would buy the close if the next day was going to close higher and sell the close if the next day was going to be lower. Pardo used the correlation between the perfect profit and a strategy's equity curve as the objective function for optimizing a strategy's inputs. I later extended the idea by developing an ideal equity curve, generated by a stop and reverse system that reverses at perfect reversal points; see http://www.breakoutfutures.com/Newsletters/Newsletter0605.htm. However, the ideal trades defined here have the advantage of being more closely related to a specific type of trading and are therefore better able to generate performance-based targets for that type of trading.
Building a strategy based on a set of targets derived from the market of interest addresses a potential problem with approaches such as genetic programming; namely, the nearly unlimited size of the search space. The number of possible trading strategies that are possible from a program like Builder is almost infinite. Trying to find a good strategy without a well-defined, realistic target to guide the search could lead the program to consider unrealistic strategies or strategies that are fit to the "noise" (i.e., random movement in the market), rather than the "signal" (i.e., non-random, tradable part of the market). Although out-of-sample testing and real-time tracking are intended to screen out the over-fit strategies, building based on targets derived from ideal trades may be just what's needed to avoid over-fitting in the first place and improve real-time performance.
*This article appeared in the December 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.
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.