OPEN-SOURCE SCRIPT

Per Volume Price Impact

Liquidity, Information and Market Timing



* Market Liquidity
The term liquidity can refer to many things in finance. In this article, we will limit the scope of discussion to the market’s ability to transact without incurring a significant increase in volatility.
As we know, liquidity and volatility have an inversed relationship — the more ample the liquidity, the lower the volatility (attributed to transaction cost, price movement and, so on). With this understanding, we can say large movements in the market are driven by low liquidity. This does not seem to make sense because the markets are huge, how can it possibly be illiquid? Now, this has to do with how the market operates and how exchanges occur (This topic concerns the area of market microstructure).



* Order Book & the Trading Process
So how does a transaction actually occur in the market? Let’s assume we open a position with a market order. In this case, you will get the price on your quote board if there are enough units of assets people are willing to sell at that price. If there are not enough units, you will buy from the second-best price and so on until your order is filled. Now in the second case, as the order is being filled, the change in price is recorded. Therefore, if someone wishes to move the market, theoretically, they just need to buy up or sell up but it is problematic to do so.

Here is why:
while dry up the liquidity can make huge moves, it is inefficient to do so.
it takes a lot of money to do that
your position will be exposed, someone more resourceful than you may go against you and that is a huge risk
market manipulation charges
when you open a position, the entry price of the position is essentially a VWAP (volume-weighted average price). If you attempt to move the market and open a buy position at the same time, you will have a higher VWAP, eating into your own profit.

I think these reasons are sufficient in establishing why opening a position and drying up liquidity to profit is a dumb idea. But of course, the institutions are not stupid, the alternative is to enter your position first then move the market.

To measure liquidity one of the tools people use is the order book. It can offer an overview of the sentiment (by looking at the orders and changes in volume) and how people are positioned (if the broker offers such data). In my opinion, open interest is a much better tool than order as it records the transactions that have occurred, hence less prone to manipulations (google: “Navinder Singh Sarao”, the trader who used fake orders to manipulate algorithms to crash the market).

But to quantify the order book is so much work as well (there are ways, just difficult), what we can do is to make things simpler.



* Quantify Market Impact
We know price and volume reflect information, while the past technical information has no predictive power per semi-strong form of EMH, empirical studies have often tested this theory over a longer time horizon. In our case, precisely due to the mechanism of exchange and human behavior (The lack of incentive to move the market right away) we can, in the very short term (often intraday), foresee if the market is going to move or not. Back to the very definition of liquidity being the ability to transact without moving the market significantly, we can take this definition and quantify it with this formula:
Market Impact = (High — Low) / Volume
Why specifically “high — low”, because that’s the complete information in that moment and it is corresponding to the volume. A little crude but it is the simplest form.

A few things to take note of here:
We can only know the complete picture once the candle is complete. This is fine in most markets because it takes time to gather money and orders.
We often see high liquidity during certain time of the day, for example, when the market opens and so on. As a result, we need to take some scientific approaches to transform the data.

Now, this looks much better. To interpret this graph, the lower the value, the lower the market impact, the deeper the liquidity.



* Generate Tradable Insights

To generate trade ideas isn’t a difficult task, we all know the RSI, MOM, STOC, etc. all the indicators attempt to draw boundaries, and we can do the same but we need to be a little more advanced and critical.

step 1: we first need to normalize the data. To do that we will take the log of the values to make the skewed distribution normal. The result isn’t ideal if you zoom out but I think this is decent enough to work with. Here is
This is still not a stationary time series, but it looks stable enough and it mean-reverts. So we turn to our lovely standard deviation bands for help.

Step 2: Because this is not a stationary process (visually, you can test it statistically if you wish), we cannot just take sample mean and SD and also because we want to show off our data skills, so we turn to move averages and regressions. I’m going to use moving regression here because I think it is better (mean can be distorted by large values by a larger margin and it lags)

I’m using the moving regression band on TradingView and 1.5 SD here for convenience, you can try to optimize the parameters with codes or other regression models if you wish. But I think it is more important to understand the rationale here.

This step is essentially trying to figure out the anomalies in liquidity so that we can see when there is deep liquidity. This is also why choosing the parameter is crucial because you are essentially approximating how much informed trading is taking place (This is a concept in market microstructure for brokerages to set their spreads but it is not a good tool in a liquid market). By setting the level at 1.5 we are assuming about 86% of the time the market is in what we consider a normal liquid state. (again it is arbitrary, but based on the 68–95–99.7 rule of normal distribution). The rest of the time will be either low or high liquidity, When liquidity is deep, it perhaps, signals institutional money is pouring into the market and big moves may follow.



* Conclusion
There you have it, how to enter the market with the big bucks. But do take note there are plenty of assumptions and a lot to improve on here.


liquidtyVolatilityVolume

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer