At the core of VPVR there’s a concept called “bucketization”.
Question: what is bucketization?
Answer: bucketization consists of identifying metrics with high predictive power and combine them appropriately.
I think this is a problem of bucketization because what the VPVR does is to take a price range, divide it into buckets and fill them up with the that was produced in each bucket’s range over the given period.
The more we divide our price range the finer the resolution, but also the less significant each bucket will become.
The steps are:
1. Get the price range with min and max over the give period;
2. Divide the range into buckets;
3. Loop over each candle of the given period and proportionally assign to one or more bucket.
Question: how to assign to buckets?
Answer: we need to calculate the right amount to add to each bucket for each candle. If 20% of a candle lies on a bucket then that bucket needs to have 20% of the of that candle, the rest 80% belongs to other buckets.
To get the percentage of a candle on a given bucket we have to find the price range of the candle contained within the bucket, then divide that amount by the entire length of the candle.
How to bucketize
Question: what are the formulas of A, B, C and Target respectively?
- A = Max(candle_high, bucket_top) - Min(candle_low, bucket_bottom);
- B = Max(candle_high, bucket_top) - Min(candle_high, bucket_top);
- C = Max(candle_low, bucket_bottom) - Min(candle_low, bucket_bottom);
- Target = A - B - C.
Now that we now how to calculate the price range belonging to each bucket we need to calculate a percentage of to fill the bucket with.
The formula is trivially simple:
* Target / (candle_high - candle_low).
Question: can we distinguish between buy and sell volume? If so, how?
Answer: yes we can and the following paragraph will teach you how.
Put it simply we can use the difference between the extremes of a candle (low and high) and its close price to get the buy and sell volumes.
The formulas for that are:
- Buy = * (close - low) / (high - low);
- Sell = * (high - close) / (high - low).
I know this is rather simplicistic but it makes sense.
This script is a working progress and I’m going to give more details if necessary, just let me know in the comments down below.
Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.