Sidechair

math.pow()

Browse the reference

Returns base raised to the power of exponent.

Try it in the editor

math.pow(base, exponent) multiplies base by itself exponent times for whole exponents, and handles fractions through roots: math.pow(x, 0.5) is the square root.

A negative base with a fractional exponent has no real result and gives na. Zero to the power of zero is 1.

Syntax

Pine Script
math.pow(base: simple int/float, exponent: simple int/float) -> simple float
math.pow(base: input int/float, exponent: input int/float) -> input float
math.pow(base: const int/float, exponent: const int/float) -> const float
math.pow(base: series int/float, exponent: series int/float) -> series float

Arguments

NameTypeDefaultDescription
baseconst/input/simple/series int/floatrequiredThe number that is multiplied by itself exponent times. na gives na.
exponentconst/input/simple/series int/floatrequiredThe power to raise it to.

Returns

const/input/simple/series float: base to the power of exponent.

Remarks

  • A negative exponent gives a reciprocal: math.pow(2, -1) is 0.5.

Example

Pine ScriptCompound growthOpen in editor
//@version=6
indicator("Compound growth")
growth = math.pow(1 + 0.01, bar_index)
plot(math.log(growth), "Log growth", color = color.blue)

See also

Runs on Sidechair