The growth in the electronic trading of stocks, futures and options with its low commissions and speed of execution has allowed market data networks that support high-frequency trading by retail customers. Now, retail can keep pace with the sophisticated institutional trading desk while maintaining the flexibility inherent in independent, small-scale trading decisions.
Indeed, high-frequency automated trading strategies — scalping techniques — are being employed by individual traders. Once out of reach of retail, these high-frequency scalping programs are being automatically deployed in the markets. Competition among traders and their trading programs remains, however, and markets have evolved so that it’s still difficult to profit on a short-term basis.
Here, we’ll examine automating and executing a high-frequency scalping strategy in the CME Group E-mini S&P 500 futures market. We’ll look at both backtest and realized trading results of a fully automated strategy and address why actual results don’t always hold up.
Today’s trader has a wide variety of direct-access trading platforms to choose from. These trading desktops provide real-time data, down to the tick, sophisticated charting and indicator tools, and often a means of automating trade strategies, including backtesting and the ability to run strategy automation unattended in real time. Strategy development and execution may be accomplished from a self-contained programming environment or by integrating more traditional programming.
Although there are other options, TradeStation is one program that provides a good example of what today’s trading workstations can do. Its built-in programming environment facilitates rapid implementation and automation of trade strategies. In addition, a function that ties the trading system code to the broker’s trade network relieves the user from many of the complexities of automation.
Referred to as the TradeManager, it includes logic to ensure that the trader’s strategy code and actual account position remain synchronized. For example, if an order is partially filled, the TradeManager ensures that the strategy code and the outstanding orders in the trade network remain synchronized until the position is closed. This architecture is explained by the schematic shown in “Trading system flow chart” from the point of view of the strategy developer.
The development of tools such as TradeManager was one of the last pieces of a bridge allowing individuals to crossover from traditional directional system trading to ultra-short term high-frequency scalping.
Our example will use an algorithm based on a well-known mean-reverting principle: If the market has crossed an outer price envelope, then when it returns to the center of the envelope it enters the market in the direction of the outer envelope. This is a standard algorithm for a retracement to mean value. Average true range bands are a good choice for calculating the upper and lower envelope values, and an exponential moving average provides a good value for the mean-reversion price.
One advantage of the mean-reverting algorithm is that it enters the market using limit orders. Many proponents of day-trading electronic futures advocate entry based on the strict use of limit orders to eliminate slippage. But while the use of limit orders enforces a discipline on trade entry, it also becomes an Achilles heel.
The strategy, which we’ll refer to as Scalper, will attempt to scalp several ticks (one E-mini S&P 500 tick is 0.25 points, worth $12.50) and exit a position with a profit-target limit order. A stop-loss market order is entered as soon as possible after entry. The stop-loss level is typically several times larger than the profit target. Because of the inherent volatility of the E-mini S&Ps, many day-traders prefer to enter at least a two- to three-point (eight- to 12-tick) stop. Such considerations are taken into account when the strategy is configured for actual execution.
“In the market” shows a chart where the strategy executed 10 trades: nine winners and one loser. The price envelope is breached to the upside (blue line) at 11:44 on the chart (second time). After which, four successful long entries are made. This sequence terminates with a losing trade. At 12:03 the price envelope is breached to the downside (red line). One successful short entry trade is made. Another breach to the downside occurs at 12:12, and this is followed by four successful trades. In this period the strategy performed well.
OPTIMIZATION AND PERFORMANCE
The Scalper algorithm has a number of parameters that can be optimized. These include:
• Price envelope width
• Price envelope and average length
• Profit-target and stop-loss values
The goal in strategy testing is to limit the number of parameters optimized and to test over a reasonably broad history. Then, if an optimization shows a reasonably good equity curve and meets certain performance criteria, the configuration is backtested over a different and typically longer history. If the strategy continues to do well on the new out-of-sample data, then it increases confidence that there is merit to the strategy (see “Evidence-Based Technical Analysis,” David R. Aronson, John Wiley & Sons, 2007).
The Scalper was tested over a number of interval price bars (one-, three-, five-, 15- and 30-minute, etc.). The algorithm gave its best performance using one-minute bars. By running the strategy at such a high frequency, backtesting produces a large number of trades. This provides more statistical confidence in the hypothetical results.
Initial tests of the Scalper on a single E-mini contract produced nearly $40,000 after about 4,800 simulated trades. Based on this success, the Scalper was backtested over a three-year price history, earning roughly $55,000 after about 8,000 simulated trades and including a $5 round-turn commission charge.
Two of the most important optimizations for a strategy such as this are profit targets and stop-loss values. Because this is a scalper strategy, we can expect a small profit target. Backtesting shows that a two-tick, or 0.50-point, profit target in the E-mini is optimal (see “Take the money and run”). The optimal stop loss proved to be in the range of 2.5-3.0 points.
The winning percentage and maximum number of consecutive winners/losers are a result of the profit target/stop loss ratio. When this ratio is low, a profitable strategy will have a high percentage of winners. While the 85% profitable trade percentage is impressive, it is largely due to this 0.50/2.75 (=0.18) profit target/stop loss ratio, which is important when actual trade performance is analyzed.
A “null hypothesis” test was performed to determine the efficacy of the Scalper strategy. Given the low profit target/stop loss ratio (0.18) it was important to determine if any program using these values would generate a profitable equity curve. “Under water” shows the result of this test over a three-year backtest period.
The Scalper trades were placed at random within a fixed-length time interval, simulating a random scalper position and with an approximate similar trade frequency. From this result, it was possible to reject the null hypothesis for the strategy: Random executions using the same trade management produced a negative result.
The Scalper program showed best results over a one-minute time frame. TradeStation processes a user’s strategy code once at the close of every bar. If a strategy generates a buy or sell order at the close of the current bar, the market can be entered at the open of the next bar. However, until the close of the bar on which the entry was made, the strategy cannot enter a stop loss or profit target. As a consequence, the strategy can go for up to a minute without a stop loss or profit target in place. This is important in terms of its profitability.
For example, the expectation is for an average winning trade to total 0.50 point * $50 per point - $5 round-turn commission = $20 per contract. However, the TradeStation three-year backtest reports an average winning trade of $23.82. The difference is due to the benefit of a one-minute gap in the placement of target-profit limit orders. That is, the market may gap up during the period between when a position is entered and when the target-profit limit order can be placed.
Of course, the same phenomenon may occur to the losing side as well. If stop loss orders are not immediately placed, then it is possible to see slippage in a fast market. However, because a 2.75-point move is larger than a 0.50 point move, it is not as common.
Assuming $20 is the maximum winning trade profitability, if all profits are exactly 0.50 point profit-target limit fills, then the one-minute gap phenomenon gives a 23.82 / 20.00 = 1.2 times increase in per trade profitability. This is used in developing an expected profit calculation.
Another unexpected aspect of the Scalper strategy has to do with the logic used to close a position when neither a profit nor a loss occurs. Backtest optimizations showed that an optimal expiration time was 20 minutes. If a trade remains open after 20 minutes, the strategy closes the position at the market.
A three-year backtest shows that this condition occurred 356 out of a total of 9,931 trades, about 3.5% of the time. When this does occur, the position may close for significantly less than the 2.75 point stop loss level. The three-year backtest performance summary shows that losing trades closed for an average loss of approximately $93 (excluding commission), or about two points. The trade expiration phenomenon decreases trade losses by 1 - 2.00 / 2.75 = 28%. This is a significant value and is also used in developing an expected profit calculation.
Based on target-profit and stop loss levels, and the win/loss percentages from backtesting, the expected profit calculation for Scalper is:
(0.50 points) * (0.85) - (2.75 points) * (0.15) - 0.1 points = -0.0875 pts
Subtraction of 0.1 points represents the $5.00 per round-trip commission overhead (0.1 * $50 = $5).
Next, including the one-minute gap and trade expiration factors gives:
(1.2) * (0.50 points) * (0.85) - (0.72) * (2.75 points) * (0.15) - 0.1pts =
(0.51 - 0.29 - 0.10) points =
This equals a $6 profit per contract per trade. This is consistent with the strategy report of $63,545 net profit in 9,931 trades over a three-year period ($6 * 9,931 = $59,586).
We have used a conservative value for commissions, namely 0.1 points, or $5 a round turn. Obtaining even a moderate volume discount could reduce the commission overhead to 0.08 points. Assuming this, the expected profit calculation for the Scalper strategy is (0.51 - 0.29 - 0.08) points = 0.14 points = $7 per trade per contract.
Having a working expected profit calculation for the strategy, we can go ahead and compare the expected result with actual trade results.
ACTUAL TRADING RESULTS
The Scalper was run in the E-mini S&P 500 market Jan. 28, 2008, through March 4, 2008. It was not run every trading day, and it was occasionally disabled to debug known problems. Over the approximate five weeks of testing, 215 trades were executed. This is 66% of the expected trade volume as determined by the three-year backtest.
During this period, two sets of data were maintained:
• The strategy-reported trades: strategy trades that would have been reported had the trading period been a part of backtesting.
• Actual strategy trades that were executed in the market.
When the strategy was not trading against the market, strategy backtest trades were not included so that identical trading periods were compared.
“Real vs. potential” summarizes the results. At the end of the test period, the strategy reported a profit of $5,235, while the actual account saw a loss of $110. On the bright side, anyone who has traded the E-mini market knows how difficult it is to make a regular profit. That the Scalper, a completely automated computer program, broke even is encouraging, as well as the successful real world performance during the first half of the period.
PROBLEMS WITH FILLS
Strategy backtesting runs entirely from price data. If a limit order has a price of x and the market touches that price, then the strategy reports a fill and is in the trade. Actual trading is against the market and touching a limit price does not necessarily give a fill.
The optimized profit target/stop loss ratio for the Scalper program is 0.18. Essentially, four winners will be needed for every losing trade to break even. Because the win percentage is 85%, the Scalper should have a slight edge, and that edge is increased when the one-minute gap phenomenon occurs and stop loss protection is strictly enforced.
Unfortunately, the 85% winning percentage is based on theoretical fills that may not be realized. Because every failed trade will fill — the entry limit order will be exceeded, in this case — if the Scalper does not get enough of the 85% winning trade fills, it can become unprofitable. The question is: What is the actual fill rate of the Scalper program?
During the five-week trading period, the actual fill rate was approximately 80% of the theoretical. The fill rate can be important on both entry and exit. There are two cases: A theoretically successful trade actually may not be entered, and the theoretical win will not contribute to actual profits; and a theoretical trade actually may fill on entry but the trade may not fill at its profit target and then later turn to an unsuccessful trade.
In practice, the second case is rare. Because of the use of entry limit orders, a trade that is entered theoretically but turns to a loser always will be entered in practice. Because market orders are used for stop loss, theoretical strategy results and actual trade results will be identical in the case of losing trades (other than slippage, which is minimal in the E-mini).
As a result, the Scalper may not get enough of the successful trade fills to offset the 15% losing trades, where a 0.18 profit target/stop loss ratio requires a four-to-one win/loss rate. Consider 100 theoretical strategy trades. The strategy backtest reports 85 winners and 15 losers. But from running the strategy against the actual market, we know that there will be 0.80 * 85 = 68 winners, and all 15 losers will occur. Our expected profit formula becomes:
(0.80) * (1.2) * (0.50 points) * (0.85) - (0.72) * (2.75 points) * (0.15) - 0.08 points =
(0.4 - 0.29 - 0.08) points =
This equals $1.50 per contract per trade. This is close to breakeven and explains the difference between theoretical and actual results.
Because the ratio of profit target/stop loss is critical, it may be that a more profitable system can be developed with a different ratio. Of course, the win/loss percentages will change with the ratio.
Finally, because a successful automated strategy is so difficult to develop, and because an expected profit calculation for Scalper shows at least a breakeven result, it may be fruitful to continue developing the Scalper. In addition, the five-week test period is too limited to be conclusive.
The current generation of desktop trading platforms, high-speed Internet access and highly liquid electronic markets offers the retail trader an opportunity to participate in automated high-frequency scalping strategies. This approach is even more possible with the advent of programs such as TradeStation, that provide a programming environment that makes fast prototyping and execution of a complex trade strategy possible.
While the exercise described here did not produce a trading Holy Grail, it offers an illustration of trade strategy automation and serves as a stepping stone to future strategy development.
Michael Gutmann is managing director of VGX Capital LLC, a private investment company and registered commodity trading advisor. He lives with his wife, Sandy, and their two children, in Hillsboro, Ore.