kev22
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: January 23rd, 2022

Volume indicator positioning

Hi all,

Just getting my feet with with scripting and was curious if anyone in the community can suggest the code that anchors the default volume indicator in TradingView to the bottom of the price chart? I have "overlay = true" which has me on the chart but the position is set at the price of 0, and ends up off screen most of the time.

Thanks in advance

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: Volume indicator positioning

Hey ,

Here is an example of pinning the volume chart to current chart bottom. You can use this method to pin any kind of chart.

It uses scaling based on the current chart area and highest value in last few bars.

Code: Select all

//This indicator will show volume inversely. So if you are looking at an Altcoin, it will show volume in BTC, if you are looking at for example BTC/USD it will show volume in USD and so on. Works with all altcoins and fiat pairs.
//I find this most useful when shopping for alts to quickly get an idea of their liquidity.

// This shows an example of how to place values at the bottom of the main chart and scale with chart
//@version=5
indicator("FRM Volume Scale v1.0", "Scaler", true, format = format.volume, scale =  scale.none)

// Inputs
scalePercentage = input.int(30, "Vertical %", step = 10, maxval = 100)
lookBack = input.int(100, "Last Bars to Look", minval = 2, step = 20)

scaleFactor = 100 / scalePercentage
plot(volume, color = color.orange, title="Volume", style=plot.style_columns, transp=0) 
limit = ta.highest(volume, lookBack)
plot(limit * scaleFactor, "High", #00000000)

Return to “Request Scripts”