Returns the arithmetic mean of the numbers you pass.
math.avg adds its arguments and divides by how many were given. Pass as many numbers as you need.
hl2 is math.avg(high, low) in short form, and ohlc4 is the average of all four prices. If any argument is na, the result is na.
Syntax
math.avg(number0, number1, ...: simple int/float) -> simple float
math.avg(number0, number1, ...: series int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| number0, number1, ... | simple/ | required | Two or more numbers to average. |
Returns
simple/series float: the mean of the arguments.
Remarks
- To average a series over time, use
ta.sma;math.avgaverages values across arguments on one bar.
Example
//@version=6
indicator("Mid average", overlay = true)
mid = math.avg(ta.ema(close, 10), ta.ema(close, 30), ta.sma(close, 50))
plot(mid, "Mean of three", color = color.fuchsia, linewidth = 2)See also
Runs on Sidechair