3

Tradingview by default shows volume numbers as (K) Thousands and (M) Millions. How do I add this to a custom script I created?

For example, if I see Net Volume as 1740654.0000 on a bar, I would prefer it shows as 1.74M instead.

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
ECH5030
  • 424
  • 1
  • 4
  • 11

2 Answers2

4

study's precision with value 0 will help: https://www.tradingview.com/study-script-reference/#fun_study

//@version=3
study("My Script", precision=0)
plot(volume)
Michel_T.
  • 2,741
  • 5
  • 21
  • 31
  • Wonderful! Thank you!! – ECH5030 Mar 12 '19 at 01:00
  • To make this work in Pine V4 you need to use the `format` parameter with the `format.volume` constant: `study("Your study", format = format.volume)`. In V4 the suffix is not tied to the `precision` parameter, you can use any value. – karatedog Sep 08 '21 at 09:25
2

In Pine Script v4 I was able to format the numbers in that way using the format argument of the study function.

From the documentation:

format (const string) type of formatting study values on the price axis. Possible values are: format.inherit, format.price, format.volume. Default is format.inherit.

//@version=4
study("My indicator", format=format.volume)
Siroj Matchanov
  • 101
  • 2
  • 4