Indicator Discussed - Buying Selling Pressure

Buying Selling Pressure

The original idea behind the code is taken from http://karthikmarar.blogspot.com/

The indicator has been discussed here. The indicator can also be accessed from https://in.tradingview.com/script/0dZY9Q3k-Buy-and-Sell-Pressure/

This is a very simple Indicator using the open, High, Low and Close and the volume.

On the above link, you can see two lines one is green and another is red. Greenline represents buying pressure and red represents selling pressure. Cross over of these two lines can be used as a signal for buying and selling. you can see that it has crossed over here and prices have started rising.

But one indicator is not always enough to have good buy /sell signals. We can use this with RSI or any other indicator for refining signals. The value of buying and selling pressure is always more than 0.

Now we come to the algorithm or logic behind this indicator. Firstly this takes the lookback period as one of its inputs. I have used 14 period as look back period. In simpler terms, I have considered last 14 bars for calculation of buying selling pressure, you can always change it to any other suitable number based on your experience or time frame in which you are working.

In the candlestick chart, you would have seen tail which is formed either at the top of the bar or bottom of the bar. The tail is formed at the top of bar when prices go up and come down due to selling pressure in the given timeframe of bar. Similarly tail is formed at the bottom of the bar when prices go down and quickly come up due to increased buying activity. The level of activity is captured in the volume and length of the tail.

Taking this clue, we define buying pressure as the length of the bottom tail till close and selling pressure as tail at the top of the bar till close value.

we can use a lookback period of 14 periods to smoothen the data and to get a trend.

in mathematical terms or coding terms

Buying Pressure(BP)  = Close - Low

Selling Pressure (SP)= High – Close

the above is for one bar, but we need average for last 14 periods i.e. the lookback period.

so we can take EMA of BP and SP for last 14 days like

BP average =EMA(BP,14)

SP average = EMA(SP,14)

Now, we will compare the buying pressure of the current bar with average buying pressure. Similarly, I will compare selling pressure of current bar with average selling pressure, this can be done in many ways, but the best way is to take percentage. we will define it as normalized buying pressure and normalized selling pressure and denote them by NBP and NSP

so NBP = BP/BPaverage

and NSP =SP/SPaverage

till this point I guess everyone would be able to follow, now keep focus and see what we are doing next. We will try to include volume in this. It is necessary as one may have a long bottom or top tail but without much volume then this has no meaning. 

For this, we can calculate the average volume of the last 14 periods and compare the same with the current volume. like

NV = volume/EMA(Volume,14)

We have intentionally made volume in this way so that the order of NBP and NSP are comparable with NV. Value of all of these would be above 0 and would seldom cross 1. Why it would seldom cross one ? This is because the volume would once in a while cross average volume of 14 days and when it will cross it will be more than 1. In case, the volume suddenly becomes double the average volume the value of NV will be 2.

Now, we can multiply NV with NBP and NSP to incorporate volume in our buying selling pressure indicator.

Further, to make it smooth, I have again taken EMA

so the indicator function

nbf = EMA(nbp * nv,14)

nsf =EMA(nbp * nv,14)

 Now this is tricky, this look back period could be different from the above lookback period because this has been used to make it more smooth.

Having understood logic behind the indicator it would be easy for us to code in PINE SCRIPT.

Summary

Learn to make indicators and strategy in PINESCIPT at Creating  Trade Strategies and BackTesing using PINESCRIPT on UDEMY.

Cross overs seems to be a good option for the generation of buying selling signals. We will also need one another indicator to refine buying selling signals generated from this code. 

Resources

Highest Rated Udemy Course on PineScript - Grab your Seat Now 

Udemy Discount Coupon Code : UDEMY-JAN23 (Valid upto 30th Nov 2023)

Learn more about coding on tradingview in PineScript through Books on pinescript available on amazon and kindle.


200+ pages book100 pages book200+ pages book


Point and Figure Charts : A Time-Tested Tool for Technical Analysis

In the dynamic world of financial markets, investors and traders constantly seek tools that can provide valuable insights into market trends...