Support and Resistance Metric
Converting back of the envelope ideas to trading algorithms is extremely challenging, but requires significant attention. This could be the single item that makes your system great. In this post, I suggest a way to find more defined support and resistance metric using limit order books.
Creating a Order Book Metric
To start, I want to create a frozen moment in time where two order books appear as in the following picture. For the sake of this example, I assume other signals have detected a $20.00 resistance level.
Blue represents the limit bid and orange the limit ask. The order book on the left suggests strong resistance at 20, while the order book on the right suggests weakness . If you’re not convinced, see my post on the support and resistance in the limit order book.
The idea above is great in theory. How can you quantify the above two situations so that it’s actually useful? Otherwise, it’s just another fluff technical analysis piece with no real substance.
A successful method applied to Figure 1 should determined if a short position should be entered at $20.00 (left) or not (right).
The first of two decisions that you must make is how far to look into the order book — a value I will call N. The above two order books have N = 4 because each side of the book contains orders at 4 different price levels.
Of course this will depend on your access to data. However, you might also find through back testing that increasing N provides no useful information.
The next decision you have to make is how to weigh the volume in the order book.
You might be foolish to think that each level of the order book is created equally.
For simplicity, I am going to describe a linear weighting system where ticks closer to the price midpoint are given more weight. Referring to the first order book example, N=4 implies we need four weights on the ask side. My system has weights that satisfy the following conditions:
- w1 – corresponds to $19.99
- w2 – corresponds to $20.00
- w3 – corresponds to $20.01
- w4 – corresponds to $20.02
- w1+w2+w3+w4 = 1
- w1 > w2 > w3 > w4
These weights essentially alter the volume in the order book so that overcoming the level of resistance is a more pronounced event. Here’s how you can choose them for a linear case.
- w1 = N = 4
- w2 = (N-1) = 3
- w3 = (N-2) = 2
- w4 = (N-3) = 1
- total = w1+w2 + w3 + w4 = 10
Through a process of normalization, the final weights are found as follows
- w1 = N/total = 4/10 = .4 = 40%
- w2 = (N-1)/total = 3/10 = .3 = 30%
- w3 = (N-2)/total = 2/10 = .2 = 20%
- w4 = (N-3)/total = 1/10 = .1 = 10%
Notice that the whole system comes by simply defining N, thus is easy to generalize and back test in your trading system.
The next step is to compute the average weighted price that would have to be paid if a market buyers chooses to pass the level of resistance. Again, I will refer to figure 1 on the ask side of the market. This will show the difference between a strong level of $20.00 resistance (left ask book) and a weak level of resistance (right ask book)
Average price (left ask book) : $19.99*2+$20.00*8+$20.01*4+$
Average weighted price (left ask book) : $19.99*2*w1+$20.00*8*w2+$20.
Average price (right ask book) : $19.99*2+$20.00*8+$20.01*1+$
Average weighted price (right ask book) : $19.99*2*w1+$20.00*8*w2+$20.
From the weighting system, you can see that a assumed resistance of $20.00 is passed by only paying an average (weighted) price per share of $19.998 during a time of weak resistance.
The weighted average price shows more defined support and resistance levels
Finally, to generate a solid metric, I considered the percent movement a stock would have to take to move past a weighted average price. For example:
Left ask book (strong resistance) : 100*(current price – average weighted price)/current price = 0.11%
Right ask book (weak resistance) : 100*(current price – average weighted price)/current price = 0.094%
My rule is set so that if the current price must move over 0.10% weighted average order book price (for a given value of N) then the resistance level is strong. Less that 0.10% makes me think the resistance is weak, and would signal for me to not initiate a short position.