This will give you what you're looking for.
//@version=4
study("Decimals", overlay=true)
var int decimals = int(log10(1/syminfo.mintick))
if barstate.islast
label.new(bar_index, high, tostring(decimals))
Improved version.
//@version=4
study("Decimals", overlay=true)
var int decimals = str.length(tostring(syminfo.mintick))-2
if barstate.islast
label.new(bar_index, high, tostring(decimals))
Another implementation by KryptoNight can be found here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…