Bar volume in $ + help
Posted: Thu Jul 29, 2021 3:05 pm
Hey guys, I wrote a simple script to show the bar average price (high+low /2) and more importantly for me the volume of the bar in USD. For me, it's easier to understand. Here's the thing - I just get an astronomical number. . Is there a simple way to break it down and show it in a string, to 3 decimal places? I use this specifically on altcoin charts to see the actual BTC value in $.
e.g.
$1000
$1.000K
$123.000K
$1.000M
.... etc.
I'm especially interested in showing that value for the bar the cursor is focused on. Any help is much appreciated. And thanks.
e.g.
$1000
$1.000K
$123.000K
$1.000M
.... etc.
I'm especially interested in showing that value for the bar the cursor is focused on. Any help is much appreciated. And thanks.
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PorkkChop
//@version=4
study("Average Bar Price & Volume $")
BTCpriceInUSD = security("BINANCE:BTCUSD", "", close)
averagePrice = ((abs((high + low)/2))*BTCpriceInUSD)
plot(averagePrice, title = 'Av Price $')
totalVolume = volume * averagePrice
//totalVolumeString = tostring(totalVolume, '#,#,#.###')
plot (totalVolume, linewidth=2, color=color.red, title = 'Volume $')