Sidechair

math.log10()

Browse the reference

Returns the base-10 logarithm of a number: the power of 10 that gives it.

Try it in the editor

math.log10(1000) is 3 because 10 to the power of 3 is 1000. It is defined for positive numbers and gives na for negatives.

It counts digits: math.floor(math.log10(volume)) + 1 is the number of digits in a whole-number volume.

Syntax

Pine Script
math.log10(number: simple int/float) -> simple float
math.log10(number: input int/float) -> input float
math.log10(number: const int/float) -> const float
math.log10(number: series int/float) -> series float

Arguments

NameTypeDefaultDescription
numberconst/input/simple/series int/floatrequiredThe number to take the base-10 logarithm of. 0 or below gives na.

Returns

const/input/simple/series float: the base-10 logarithm.

Remarks

  • Use it to compress series that span many orders of magnitude, such as volume.

Example

Pine ScriptVolume on a log scaleOpen in editor
//@version=6
indicator("Log volume")
plot(math.log10(volume + 1), "log10 volume", color = color.teal, style = plot.style_area)

See also

Runs on Sidechair