Figure 1. TradeStation price chart showing the E-mini S&P with the E-mini NASDAQ as data2, E-mini Euro as data3, E-mini crude oil as data4, and the CBOT Treasury Index as data5. The correlations between the ES and each other market are also plotted.
This collection of markets provides a second stock index, a currency, a global commodity, and an interest rate. As shown in Fig. 1, I plotted the correlation coefficient between the ES and each of the other markets. I could have also plotted the correlations between the other markets, such as the correlation between QM and E7, but I chose to limit the factors to those directly involving the ES for the sake of simplicity.
I used Adaptrade Builder to perform the genetic programming calculations. Builder allows the correlation indicators shown in Fig. 1 to be read in and included in the build process, as shown below in Fig. 2.
Figure 2. Including the correlation coefficients as custom indicators, read from the price file.
Each of the correlation coefficients read in from the price chart data becomes a custom indicator in Builder. The four indicators listed in the Custom Indicators table in Fig. 2 are, respectively, the correlation between the ES and the NQ, the correlation between the ES and the Euro, the correlation between the ES and mini crude oil, and the correlation between the ES and the treasury index.
All four indicators were included in the so-called build set of Builder, as shown in Fig. 3. This means the GP algorithm will consider using them in constructing strategies. I also included other indicators in the build set, including price patterns, the day of week indicator, moving averages, and the highest and lowest functions. These other indicators were included to test whether or not the correlation coefficients were better or worse than some other, common indicators. I also selected the option to make the long and short sides symmetric, which means the same logical elements will be used for entering each side of the market with the inequality operators reversed for the opposite side.
Figure 3. Including the correlation coefficients in the build set for genetic programming.
To build a strategy in Builder, it's necessary to specify a set of performance metrics. These are shown in Fig. 4. I ran 10 builds altogether. In half, I set a target for the net profit of $80,000. In the other half, I maximized the net profit. In all cases, I set targets for the correlation coefficient of the equity curve, the return/drawdown ratio, and the average bars in trades. I also set it to minimize the complexity using a relatively small weight value of 0.2. All other metrics used a weight value of 1.0, so the complexity goal was designed to give a small bias to strategies with fewer inputs.
Figure 4. Build goals for genetic programming.
The time period for building strategies is shown below in Fig. 5. The ES price data consist of daily bars from February 2005 to September 2011. I set aside the most recent 25% of data for out-of-sample testing, which means the strategies were built over data from 2/2005 to 1/2010. Trading costs of $30 per round turn were used.
Figure 5. Market settings for the genetic programming process.
A shown in Fig. 6, the strategies were built using a population of 1000 members, evolved over 20 generations. I also used an option in Builder to re-initialize the population (basically, starting over from scratch) if the out-of-sample equity curve failed to achieve a correlation coefficient of at least 0.90 after 10 generations. In other words, I wanted the out-of-sample equity curve to be nearly straight.
Figure 6. Various options for building the strategies using genetic programming.
Ten separate builds were conducted. In nine out of 10 cases, the following entry logic was selected by the GP process:
In some strategies, the inequality operator was "<=" rather than "<" or the statement was reversed but with the same meaning (i.e., ...data4.. < ...data3...). In all nine case, though, the correlation of the ES with the Euro was compared to the correlation of the ES with crude oil.
The long entry condition (EntCondL) can be interpreted as "Entry conditions for a long trade are favored if the correlation between the ES and the Euro is stronger than the correlation between the ES and crude oil". Likewise, short entry conditions (EntCondS) are favored if the opposite holds true.
Interestingly, none of the top strategies included conditions that compared the correlation coefficient to a fixed number, such as correlation(C of data1, C of data2, 15) > 0.6.
In one case, the top strategy consisted of entry logic that did not include any of the correlation coefficients. In this case, the entry logic involved price patterns.
While the entry logic was quite consistent, the type of entry and exit orders varied somewhat. Most entries occurred on stop orders, although the stop price was calculated in different ways. A variety of exit types was used in the strategies from the different builds, including target exits, exiting after a fixed number of bars, exiting based on a separate logical condition, and so on.
Fig. 7 shows the equity curve for the top strategy from one of the builds.
Figure 7. Closed-trade equity curve for an ES strategy using intermarket logic.
The EasyLanguage code for the strategy shown in Fig. 7 is listed below.
The fact that nine out of 10 GP builds chose to use the correlation coefficients rather than moving averages or price patterns suggests there may be some utility in intermarket analysis for trading the E-mini S&P on daily bars. More interesting is the fact that the top strategy for each build that settled on correlation coefficients used them in an unusual way. I'll leave it up to someone with a better understanding of fundamental analysis than me to determine why it might make sense to trade the long side of the ES when it's more correlated to the Euro than to crude oil. Whatever explanation one might impose to justify that logic, the fact remains that the GP process consistently found that relationship to provide more benefit than any other one it examined. It's also interesting to note that the GP process didn't find utility in the correlations between the ES and either the NQ or interest rates.
I have no doubt that some traders would be uncomfortable trading a strategy that uses logic for which they can't find a fundamental explanation. It reminds me of what happens every day on the financial news programs after the markets close. Regardless of which way the markets moved that day, the commentators and analysts look back on the day and try to explain why the markets went up, down, or sideways. However, I suspect that trying to fit an explanation to the market's behavior after-the-fact probably matters very little to all the traders who either made or lost money that day.
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.