Quantifying the opening range day trading strategy

It’s Thanksgiving Break, which means no classes or homework. For the past year, I’ve been using most of my free time during breaks like this to build things (web apps, trading algs, etc.). Before that, I used to have the old habit of playing online poker–not really building anything but playing games of calculated risks and personal discipline in order to win more money than I lost. I decided to satisfy my old gambling addiction  affinity for games of wit by day trading today.

I day traded AAPL, using a strategy called opening range breakout. I made about $70, which is a decent amount considering the money allocated to day trading was very small, and I only spent a total of a few hours actually doing stuff.

Whenever there’s money on the line, I always look for a quantifiable edge. So I decided to throw some statistics at the opening range day trading strategy.

The opening range day trading strategy

Here are the basic rules to the opening range strategy (caveats at the very end of this post):

  1. Use 5 min bars. Wait 30 minutes from open
  2. At 10am, determine the highest and lowest points the stock reached in the past 30 min. This is the opening range
  3. If price breaks above the opening range later in the day, enter a long trade. If price breaks below the opening range, enter a short trade. I like to wait for a confirmation (e.g. a second up bar on strong volume after the first break above the opening range) before entering.

Python programming

Next was a lot of python programming; as usual, pandas was infinitely helpful in dealing with time series and data tables, as was ipython and pdb for interaction with variables and debugging. I wrote up scripts to transform the data (all I had access to was consolidated trade data, so I had to transform it into 5 minute data), codify the trading rule, and generate statistics and graphs for the ‘event study’-style tests I ran.

I’ve uploaded my code and data files to my github: https://github.com/troyshu/openingrangestrat. Here’s a description of the important files:

  • openDayRangeES.py is a script that generates the data tables needed to conduct the event study tests on the strategy
  • the csvs labeled with “odr” are the data tables created from the openDayRangeES.py script (consolidated into aapl_odr_all.csv)
  • openDayRangeStats.py calculates the stats, does the regressions, and generates the graphs from data in aapl_odr_all.csv

The quantifiable edge

Now for the part that matters. The results are based on concepts I call “max and min profit”. Max profit is the maximum amount of money we would’ve made that day after a breakout signal assuming we got out at the highest price that AAPL reached that day (or lowest price if we’re shorting). Min profit is the most amount of money we would’ve lost that day after entering like the breakout signal told us to do (e.g. in the long case, we get out at the lowest price that AAPL reaches that day, after the entry signal).

The graph above shows pairs of box plots for short and long trades. The upper box is for max profit, the lower box is for min profit. We can see that the return distributions for short and long trades are roughly the same. More importantly, the average max profit (~ +0.008% for both long and short) is much higher than the average min profit (-0.0024% for shorts, -0.0019% for longs). This is the quantifiable edge.

How has the quantifiable edge changed over time?

Answer: not much.

The above graph plots the time series of max and min profit over time. Note that in both series there does not seem to be a trend, so our edge seems to be pretty consistent (at least for AAPL, over a 7 month period).

Are there any factors that can improve our edge?

Yes, there are many. The immediately quantifiable ones were the range width in percentage (range high/range low – 1) and the “signal delay”, or the number of 5 min bars that had elapsed between the formation of the range and the breakout signal to buy or short. Other important factors to the opening range strategy are discussed in the caveats section below.

The graph above shows max profit (blue) and min profit (red) when trades are grouped into range width by quartile. The top quartile (quartile 4) contains the top 25% of trades with the largest opening ranges. Max profits are highest and min profits are lowest in this quartile. This is to be expected, as a larger opening range signifies more volatile price action, and so potential profits are higher and losses are larger. No guts, no sausage. That’s supposed to mean “no risk, no reward”, by the way. Whatever.

This one shows max and min profit when trades are grouped into signal delay by quartile. So the top quartile (quartile 4) contains the top 25% of trades with the longest delay (in minutes) between the actual formation of the opening range (at 10am) and the breakout entry signal (which could happen as late as 10 or 5 minutes before the 4pm close). The trades that have the highest max profit are those that occur soon after the opening range is formed–this signifies that prices are moving rapidly (a breakout of the range occurs just a few minutes after it is formed) and so are more decisive when they move in a certain direction. Interestingly, the max profit for the 4th quartile is also relatively high, and the min profit is positive. This could have something to do with the tendency for institutions to load/dump their positions toward the end of the day, thus driving the prices in apparently the same direction as the original opening range breakout.


Using the opening range strategy to day trade AAPL stock has a quantifiable edge. Things to do: other stocks, other time periods (what happened during the crisis?).


There are so many caveats and so many more things that could have been quantified and tested, but I will boil it down to one notion: the success of the opening range strategy still depends heavily on the trader using it.

The trader decides how he manages risk–his discipline and and skill determine how he cuts his losses and takes his profits. This could be based on technical analysis/chart reading experience, financial goals, even intuition. So things like using support and resistance levels for stop losses and profit targets, engaging in volume analysis, and interpreting candlestick patterns are not accounted for: they all contain subjectivity and are hard to quantify. That means that this is an area ripe with asymmetric information, and area with opportunity. How else do human traders (and even human investors like Buffett) compete in a market overrun by algorithms. At least now us humans can nurture an edge that has been quantitatively shown to even exist in the first place.

Leave a Reply

Your email address will not be published. Required fields are marked *