Price Pattern Strategies
by Michael R. Bryant
Trading strategies based solely on price action seem to have a unique appeal among traders. Unlike standard technical indicators, price patterns often have zero lag, which means there is no delay between when the market moves and when that movement is picked up by the price pattern. It's probably also true that many traders have been disappointed by strategies based on standard indicators, which leads them to pursue other approaches. Price patterns in particular are arguably a logical way to directly represent patterns of trading behavior, which all trading strategies seek to exploit in one way or another.
This article discusses the process of finding viable trading strategies based on price patterns using Adaptrade Builder, a strategy development application for Windows. Builder includes an entry for "Price Patterns" in the table of indicators that can be used to construct entry conditions consisting of price patterns. I'll show how to construct a strategy using this "indicator" in Builder for 10 minute bars of the E-mini Russell 2000 futures.
A Variety of Price Patterns
The so-called Price Patterns "indicator" in Builder (see Fig. 1) is how you tell the program to use prices directly in the entry and exit conditions generated by the program. In particular, price patterns can consist of the following prices: O, H, L, C, O[N], H[N], L[N], C[N], OpenD(0), HighD(0), LowD(0), and CloseD(1), where O, H, L, and C are the open, high, low and close, respectively, and N is the look-back length. OpenD(0), HighD(0), and LowD(0) are the open, high, and low, respectively, of the current day on intraday bars. CloseD(1) is the close of the prior day on intraday bars.
Figure 1. Selecting only the Price Patterns indicator in Builder.
Some examples of price patterns that are possible in Builder are as follows:
LowD(0) <= C[N2]
(L[NS1] >= LowD(0)) and (OpenD(0) < C)
(C[N1] < C[N2] and C[N3] > H[N4]) or L[N5] > C[N6]
It's also possible to have conditions based on the difference between prices, such as the following:
(HighD(0) - L > C[NL1] - LowD(0)) or (H[NL2] - LowD(0) <= LowD(0) - L[NL3])
(L[NL4] < O[NL5]) and (H[NL6] < LowD(0))
(LowD(0) - OpenD(0) > H[NS3] - C[NS4]) and (H[NS5] >= LowD(0))
Notice that each condition consists of one or more inequality expressions connected logically by either "and" or "or". The program constructs these types of patterns as part of the build process. Internally, the expressions are built up in a tree structure, such as shown in Fig. 2. It starts with a logical operator, such as the "and" operator at the top of the tree in Fig. 2. Each branch is built using one or more levels of inequality operators. Below each inequality operator is either the price itself, such as in the right-hand branch below, or the minus operator (-), which is used when comparing the difference between two prices.
Figure 2. Tree structure representing a price pattern. The structure shown represents the expression (LowD(0) - OpenD(0) > H[NS3] - C[NS4]) and (H[NS5] >= LowD(0)). This tree has a tree depth of 3.
If only the Price Patterns indicator is selected in the Indicators table, then only simple prices, as described above, will be available when the program constructs the tree structure. This will result in pure price patterns. However, if other indicators that return a price are available, they may be chosen in place of simple prices. For example, if the Bollinger bands indicator has been selected in the Indicators table (see Fig. 1), that may be used as one of the nodes in the tree because Bollinger bands return a value that is a function of price and is therefore comparable to prices (in particular, Bollinger bands are calculated as the average price plus or minus some number of standard deviations of price). The same applies to Keltner channels, moving averages, and the Highest and Lowest indicators. Selecting these other indicators could result in a condition such as H[N1] < Average(C, N2), for example, which is not a pure price pattern. However, the Highest and Lowest indicators can be considered valid elements of a price pattern, such as in Highest(C, 10) < C, and may be selected along with the Price Patterns indicator when building price pattern strategies.
The price patterns constructed by Builder are used in entry and, optionally, exit conditions to determine whether or not to enter or exit a trade. For example, if the price pattern is L < O, then an entry order might be placed for the next bar if this condition is true on the current bar.
Figure 3. Price data selection and market settings for building a price pattern strategy.
The order types that were selected are shown in Fig. 4. The strategies were designed to enter at market and exit at the end-of-day. Optional protective stops were also selected. The strategy options shown in Fig. 5 include both long and short entries and the option to restrict trade times so that the trade exits at the open of the last bar (4:10 pm exchange time). This provides a practical way to exit the trades end-of-day, whereas the "end-of-day" exit on the Order Types tab is mainly for back-testing purposes. I also increased the look-back parameter range for the price patterns so that the look-back length could be anywhere from 1 to 100 (from the default of 20).
Figure 4. Order types selected to build a price pattern strategy.
Figure 5. Strategy options selected for building a price pattern strategy in Adaptrade Builder.
The build metrics (not shown) consisted of the net profit, correlation coefficient, and significance, all set to maximize with a weight value of 1.0, and the maximum MAE (maximum adverse excursion), set to minimize with a weight value of 1.0. On the Build Options tab (Fig. 6), I chose a population size of 2000 with five generations and the option to reset the build if the out-of-sample correlation coefficient was less than 0.9 after every five generations. I also increased the tree depth to 4 (from the default of 3) in order to allow more complex price patterns.
Figure 6. Build options selected for building a price pattern strategy over two years of 10 minute bars of the E-mini Russell 2000.
After several rebuilds resulting from the out-of-sample reset option, a strategy was found that met the out-of-sample criteria of having a correlation coefficient of at least 0.9. The equity curve in Builder for this strategy is shown below in Fig. 7. I also transferred the strategy to TradeStation and ran it on the full price series, including the two months excluded from the build and confirmed that the strategy was also profitable on the final two months of data.
Figure 7. Equity curve for price pattern strategy, including out-of-sample results (in green).
The code for the strategy is shown below in Fig. 8. The price patterns are shown in the long and short entry conditions, represented by the variables EntCondL and EntCondS. Notice that the condition for the long entry is trivially true (day's low price less than or equal to the day's open). While this might seem strange, it has the following meaning: a long trade is taken at the open of the 9:40 bar unless the short entry condition (EntCondS) is true, in which case a short trade is taken. This becomes clear when the strategy is plotted on a chart, such as in TradeStation. A long entry is taken every day. On days for which the short entry condition (i.e., price pattern) is true, the long trade is immediately reversed, and the short trade is taken.
Knowing how the logic works, the code could be modify slightly so that the long entry is not taken in practice if the short entry condition is true, which would avoid the cost of a commission on short-trade days. After entry, the trades are held until the open of the last bar. In this strategy, a protective stop was not selected by the build process. However, based on the maximum adverse excursion numbers, a fixed dollar stop of $2,000 could be added without cutting off any significant winners.
Figure 8. EasyLanguage strategy code for price pattern strategy. Together, the long and short entry conditions imply that a long trade is taken on the open of the 9:40 bar unless the short entry condition is true, in which case a short entry is taken. Trades are held until the open of the last bar.
Price pattern strategies can be constructed in Builder by selecting only the price pattern indicator from the Indicators table. The example shown in this article was for a simple day trading strategy that enters near the day's open and holds until near the close. It has the virtue of simplicity. Aside from the time range inputs, which are not optimized, the only input is a price look-back length.
Although the performance of the selected strategy is only average, it has the advantage of holding up not only over the out-of-sample period selected within the program but over the two-month out-of-sample period not included in the program. There were other strategies in the final population that had better looking equity curves, but they didn't hold up well over the final two months of data.
A more typical use of price patterns would be to combine them with other price-based indicators, such as moving averages or Bollinger bands. It might be interesting to start with a population of strategies generated with only price patterns, then select other indicators, and continue building from there. Of course, price patterns could be selected along with other indicators from the start. However, for those seeking a pure price pattern-based strategy, using the price pattern feature of Builder as the sole indicator is a viable option.
*This article appeared in the January 2012 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
Copyright (c) 2004-2019 Adaptrade Software. All rights reserved.