Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index
Function reference

math

Arithmetic, rounding, logs, trigonometry and aggregates.

29 names from PineTS 0.11.1 · 17 with full entries

math.abs

Verified
math.abs(number)

Absolute value.

math.max

Verified
math.max(number0, number1, …)

The largest of its arguments.

math.min

Verified
math.min(number0, number1, …)

The smallest of its arguments.

math.avg

Verified
math.avg(number0, number1, …)

The mean of its arguments.

math.sum

Verified
math.sum(source, length)

Sum of the last length values of a series.

math.round

Supported
math.round(number, precision)

Rounds to the nearest whole number, or to precision decimals.

math.round_to_mintick

Supported
math.round_to_mintick(number)

Rounds to the symbol's price step (syminfo.mintick).

math.floor

Verified
math.floor(number)

Largest whole number not greater than number.

math.ceil

Supported
math.ceil(number)

Smallest whole number not less than number.

math.sign

Supported
math.sign(number)

1, 0 or -1.

math.pow

Supported
math.pow(base, exponent)

base raised to exponent.

math.sqrt

Verified
math.sqrt(number)

Square root.

math.log

Verified
math.log(number)

Natural logarithm.

math.log10

Supported
math.log10(number)

Base-10 logarithm.

math.exp

Supported
math.exp(number)

e raised to number.

math.random

Supported
math.random(min, max, seed)

A pseudo-random number between min and max.

math.pi

Supported
math.pi

π.

Everything else in math

Also implemented. These follow TradingView’s Pine v6 reference for their arguments.

  • math.acosSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.asinSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.atanSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.cosSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.eSupportedEuler's number (e) The base of natural logarithms, approximately 2.718281828459045
  • math.lnSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.phiSupportedGolden ratio (φ, phi) Calculated as (1 + sqrt(5)) / 2, approximately 1.618033988749895
  • math.rphiSupportedReciprocal of golden ratio (1/φ) Equal to phi - 1, approximately 0.6180339887498948
  • math.sinSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.tanSupportedImplemented. Arguments as in TradingView's Pine v6 reference.
  • math.todegreesSupportedConverts an angle in radians to degrees.
  • math.toradiansSupportedConverts an angle in degrees to radians.

On this page

  • math.abs
  • math.max
  • math.min
  • math.avg
  • math.sum
  • math.round
  • math.round_to_mintick
  • math.floor
  • math.ceil
  • math.sign
  • math.pow
  • math.sqrt
  • math.log
  • math.log10
  • math.exp
  • math.random
  • math.pi
  • Everything else (12)