Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Yeah, only because the two before that are more meant to show you the raw numbers. With the third, it's imitating a MACD in a sense using values from the second indicator. But without exponential smoothing, the changes from one bar to the next were too erratic to really get any useful information out of it. The fast line of the indicator would fluctuate dramatically and cross below and above the signal line too often, giving far too many signals that are mostly unimportant making it difficult to discern anything of significant importance between the signals. I can always provide the code if you want to add exponential smoothing to the other two indicators if that's why you're asking. That's not a problem, I just personally don't think it's all that important to include it with the first two indicators because they're meant to show the raw volume as percentages of the candle. The raw numbers are a more important aspect with those particular indicators, in my opinion. Doesn't mean I can't include that as an option by any means, just giving you my two cents on it, but who knows it's always possible that someone sees something of more significant importance that I may have not thought about or overlooked.@jmancsn you add exponential smoothing option for the 3rd indicator?
Are you talking about the Buy And Sell Volume Pressure Averages or the BSVPACD or both? Either way, I'm sure I can implement it in either one. However, unless someone is able to answer for me whether it's possible to have an indicator display both on the chart and below the chart and how to do that, I'd have to provide a copy of either indicator that doesn't display on the bottom and only displays the arrows on the price chart itself, if that's what you're intending to accomplish.Would it be possible to add green and red arrows to the respective crossovers (whether that's in addition to or instead of the labels)?
The problem with labels is that they don't stay on the chart and therefore lose out on the history of the data.
Thank youFirst, I'll start by saying I think someone else has posted a similar base indicator for the indicators I'm about to post here, but I didn't look into the details of their calculations.
I first started by creating an indicator that essentially separates buy volume pressure from sell volume pressure. The calculation is as follows:
Buy Volume Pressure = ((high - open) + (close - low)) / 2 / (high - low) * volume
Sell Volume Pressure = ((low - open) + (close - high)) / 2 / (high - low) * volume
Edit: Below, I did my best to draw up a visual description using paint 3D of how my calculations of "Buying And Selling Volume Pressure" work. Also, I made the realization that I forgot to include "/ (high - low)" before "* volume" in the visual descriptions. Please forgive me for that for now until I update the image.
View attachment 3238
The Buy Volume Pressure is always a positive number while the Sell Volume Pressure is always a negative number. I simply call this indicator "Buy And Sell Volume Pressure" since it outputs a percentage of the volume as "Buying" or "Selling" Pressure. It also includes labels for the total volume, total buy volume pressure, and total sell volume pressure. Here's the code for the Buy And Sell Volume Pressure indicator:
Edit: Because someone asked for the percentages of buying and selling volume pressure for another indicator included in this thread, I've decided to include labels for that in this indicator as well (the code below has been updated):
Code:declare lower; def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0); def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0); def buyvolper = buyvol / volume() * 100; def sellvolper = absValue(sellvol) / volume() * 100; plot Zero = 0; plot BuyVolume = buyvol; plot SellVolume = sellvol; BuyVolume.setPaintingStrategy(paintingStrategy.HISTOGRAM); BuyVolume.setDefaultColor(color.GREEN); SellVolume.setPaintingStrategy(paintingStrategy.HISTOGRAM); SellVolume.setDefaultColor(color.RED); addLabel(yes, "Total Volume: " + volume(), color.LIGHT_GRAY); addLabel(yes, "Buy Volume: " + buyvol, color.GREEN); addLabel(yes, "Sell Volume: " + absValue(sellvol), color.RED); addLabel(yes, "BVP%: " + buyvolper, color.GREEN); addLabel(yes, "SVP%: " + sellvolper, color.RED);
The next indicator I created is a two average indicator, an average for buy volume pressure and an average for sell volume pressure. The average types and lengths are adjustable. In this case, I used the absolute value rather than the negative number output of the sell volume pressure for the sell volume pressure average. When the buy volume pressure average crosses above the sell volume pressure average it indicates that buy volume pressure is increasing at a faster rate than sell volume pressure and vice versa, or you could say if the buy volume pressure average crosses below the sell volume pressure average buy volume pressure is decreasing at a faster rate than sell volume pressure and vice versa. Here's the code for the Buy And Sell Volume Pressure Averages indicator:
Code:declare lower; input AvgTypes = averageType.EXPONENTIAL; input BuyVolumeAvgLength = 18; input SellVolumeAvgLength = 18; def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0); def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0); def buyvolavg = MovingAverage(AvgTypes, buyvol, BuyVolumeAvgLength); def sellvolavg = MovingAverage(AvgTypes, absValue(sellvol), SellVolumeAvgLength); plot BuyVolumeAverage = buyvolavg; plot SellVolumeAverage = sellvolavg; BuyVolumeAverage.setDefaultColor(color.GREEN); SellVolumeAverage.setDefaultColor(color.RED);
Last but certainly not least, I came up with a Buy And Sell Volume Pressure Average Convergence Divergence (BSVPACD) indicator. This indicator works and looks very similar to the MACD (Moving Average Convergence Divergence) indicator, however it is based on the Buy And Sell Volume Pressure Averages, can give slightly earlier signals than the MACD indicator, and divergences are more pronounced than on the MACD indicator (I honestly don't know if this has to do with the particular default settings I picked for it). What this indicator does is it calculates the difference between the Buy Volume Pressure Average and the Sell Volume Pressure Average, plots that difference, then plots an average of the difference between the two averages (the signal line), and finally plots the difference between the difference of the Buy Volume Pressure and Sell Volume Pressure Averages and the signal line as a histogram just like MACD. The average types and lengths are all adjustable. I've also included an option that exponentially smooths the difference between the Buy And Sell Volume Pressure Averages that's toggled on by default due to the fact that the change in the difference tends to be somewhat erratic. You can also change the smoothing factor which is set to 3 by default. Here's the code for the BSVPACD indicator:
Code:declare lower; input AvgTypes = averageType.EXPONENTIAL; input BuyVolumeAvgLength = 18; input SellVolumeAvgLength = 18; input ExponentialSmoothing = yes; input SmoothingFactor = 3; input SignalType = averageType.EXPONENTIAL; input SignalLength = 9; def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0); def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0); def buyvolavg = MovingAverage(AvgTypes, buyvol, BuyVolumeAvgLength); def sellvolavg = MovingAverage(AvgTypes, absValue(sellvol), SellVolumeAvgLength); def diff = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(buyvolavg - sellvolavg, SmoothingFactor), SmoothingFactor), SmoothingFactor) else buyvolavg - sellvolavg; def sigline = MovingAverage(SignalType, diff, SignalLength); def hist = diff - sigline; plot BSVACD = diff; plot SignalLine = sigline; plot Zero = 0; plot Histogram = hist; Histogram.setPaintingStrategy(paintingStrategy.HISTOGRAM); Histogram.assignValueColor(if hist > 0 and hist > hist[1] then color.GREEN else if hist > 0 and hist < hist[1] then color.DARK_GREEN else if hist < 0 and hist < hist[1] then color.RED else color.DARK_RED);
A screenshot of the indicators below a price chart of the SPY (from top to bottom, Buy And Sell Volume Pressure, Buy And Sell Volume Pressure Averages, and BSVPACD):
View attachment 3239
A screenshot of the BSVPACD compared to the MACD (MACD up top, BSVPACD on bottom):
View attachment 3240
Happy Trading!
declare lower;
input AvgTypes = averageType.EXPONENTIAL;
input BuyVolumeAvgLength = 18;
input SellVolumeAvgLength = 18;
input ExponentialSmoothing = yes;
input SmoothingFactor = 3;
input SignalType = averageType.EXPONENTIAL;
input SignalLength = 9;
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolavg = MovingAverage(AvgTypes, buyvol, BuyVolumeAvgLength);
def sellvolavg = MovingAverage(AvgTypes, absValue(sellvol), SellVolumeAvgLength);
def diff = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(buyvolavg - sellvolavg, SmoothingFactor), SmoothingFactor), SmoothingFactor) else buyvolavg - sellvolavg;
def sigline = MovingAverage(SignalType, diff, SignalLength);
def hist = diff - sigline;
plot BSVACD = diff;
plot SignalLine = sigline;
plot Zero = 0;
plot Histogram = hist;
Histogram.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Histogram.assignValueColor(if hist > 0 and hist > hist[1] then color.GREEN else if hist > 0 and hist < hist[1] then color.DARK_GREEN else if hist < 0 and hist < hist[1] then color.RED else color.DARK_RED);
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.