Search code examples
pine-scriptpine-script-v5trading

How can I view numbers as "millons" in pinescript v5?


I coded a indicator that find divergences between price and volume. In somewhere in the code I use this block to print volume:

volume_variable = volume
volume_ma_input = input.int(20, title = "Volume Moving Average Period")

plot(volume_variable, color = close>open ? color.new(color.green,50) : color.new(color.red,50), style = plot.style_columns)

plot(ta.sma(volume_variable,volume_ma_input), color = color.white)

but when I use this, the outputs looking like "1850252" and not "1.8MN" as could be seen in the image below. what should I add? thank you for your time.


Solution

  • Use format.volume in indicator parameters

    
    //@version=5
    indicator("My script", format = format.volume)
    
    volume_variable = volume
    volume_ma_input = input.int(20, title = "Volume Moving Average Period")
    
    plot(volume_variable, color = close>open ? color.new(color.green,50) : color.new(color.red,50), style = plot.style_columns)
    
    plot(ta.sma(volume_variable,volume_ma_input), color = color.white)