Rounds a number up to the next whole number; a number that is already whole stays as it is.
math.ceil rounds up: 2.1 gives 3 and -2.9 gives -2. A value that is already whole stays as it is.
Use it to size things in whole units, such as the number of bars needed to cover a duration.
Syntax
math.ceil(number: simple int/float) -> simple int
math.ceil(number: input int/float) -> input int
math.ceil(number: const int/float) -> const int
math.ceil(number: series int/float) -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| number | const/ | required | The number to round up to the next whole number. A whole number stays as it is. |
Returns
const/input/simple/series int: the whole number at or above the input.
Remarks
math.ceil(x)equals -math.floor(-x).
Example
//@version=6
indicator("Ceiling", overlay = true)
plot(math.ceil(high), "Ceiling of high", color = color.red, style = plot.style_stepline)
plot(math.floor(low), "Floor of low", color = color.green, style = plot.style_stepline)See also
Runs on Sidechair