TradingView
LonesomeTheBlue
14 de Jul de 2022 13:24

Volume [Educational] 

Bitcoin / TetherUSBinance

Descrição

Hello All,

This is an educational work and it's developed to show how to write scripts that will work like built-in volume indicator.

We have new features in Pine Script™ Language, such chart.bg_color, chart.fg_color, chart.left_visible_bar_time, chart.right_visible_bar_time and many more. Many Thanks to Tradingview and Pine Team for such great additions!
You can find more information about these new functions here.

How the script works?
- At the first step it calculates how many visible bar on the chart by using chart.right_visible_bar_time and chart.left_visible_bar_time functions.
- Calculates the zero line for the volume
- Finds maximum volume on visible area and normalize all volume values
- Draws volume bars
- Shows volume info as indicator value. in this step it uses chart.fg_color and plotarrow() commands to show the values in optimum color.

In order to place the indicator at the bottom of the chart, Please set Bottom Margin = 0 as shown in the following screenshot:


You can change the volume bar colors optionally.

An Example screenshot with different volume bar colors:



Enjoy!
Comentários
KioseffTrading
Very nice (:
LonesomeTheBlue
@KioseffTrading, Thank you :)
serdarsuveren233427
Tebrıkler hocam
friendlyEagle203
A lot of learning for a budding coder!! Always a fan of LonesomeTheBlue's work. A True WIZARD :)
davewantsmoore
Nice! Thanks.

Did you mean for the arrows to be tiny, and transparent?...... they don't display properly
plotarrow(volume, colorup=color.new(chart.fg_color, 0), colordown=color.new(chart.fg_color, 0), maxheight = 100)
LonesomeTheBlue
@davewantsmoore, it's used only to show volume values. they (arrows) should not be visible already ;)
davewantsmoore
@LonesomeTheBlue, I see... Thanks for sharing so much cool stuff.
RedKTrader
Fantastic !!! great example to steal :)
LonesomeTheBlue
@RedKTrader, Thank you :)
TradersVIP
💚
Mais