TradingView
JohnMuchow
Mar 2, 2021 5:51 PM

Volume with Configurable Moving Averages 

Pinterest, Inc.NYSE

Description

Volume with Configurable Moving Averages displays volume based on the current timeframe. For example, on a daily chart the volume shown is for the day. On a weekly chart, the volume is cumulative for the week.

There is also an option to configure the volume moving average lengths. The default for a daily chart is to calculate the 50-day moving average. On a weekly chart, the default is the 10-week moving average.

Features:
■ Configure moving average lengths for various chart timeframes.
■ Set width of volume bars.
■ Option to set bar color based on the previous close.

Learning Pine Script / Creating Your Own Indicators

One goal of this indicator is help others who are interested to learn Pine Script. The code is open source and I've included an abundance of comments. In future updates, I'll show additional Pine Script features and scripting concepts.

Release Notes

version 2.0

■ Minor updates to the interface.

Release Notes

version 3.0

■ Update to how the volume bar colors are determined.

Release Notes

version 4.0

■ Updated formatting of the volume scale on the right.
Comments
HenryGofman
Hi
I'm trying to create a simple indicator with an alert that should be triggered when volume goes above the 7 day moving average volume by more than 20%. can anyone tell me how to write this?
JohnMuchow
Hello Henry, I'd recommend looking at the various scripts that are available on TV. Many are open source and provide great insight into how to work with alerts.
royttm
Hi John, thanks for the script! In anyway do you have written scripts to include a fast and a slow volume moving average superimpose onto the volume plot?
JohnMuchow
I have not written any indicators that include both a fast and slow MA over volume.
Hyphens_Marke
Thanks a lot, very good work 👍
JohnMuchow
Thanks for the kind words! I hope you find the indicator helpful!
XiiaObaKakiA
Hello, John.

Can the color of the volume bar based on the difference of both the open price and close price of the candlestick?
JohnMuchow
Sure, you are welcome to make changes to the code for your own use if you have a preference on how the colors are determined.
Rubinj57
John, I am still trying to wrap my head around all this scripting stuff an appreciate your willingness to give me guidance.
I really like what you have done with this volume script and appreciate the notations and explanations provided.
I noticed that the TV built in indicator for volume shows the values in thousands (i.e xxxx k) which cuts down on the screen space used.
Is this something that could be added here?
Jim
JohnMuchow
Always happy to help. Can you point out what reference to the volume you are referring to? That is, where on the chart?
More