Ceiling
Element-wiseCore Math
The Ceiling node applies Math.ceil to each element, rounding every value up to the nearest integer. Useful for position-sizing logic that must never go below a whole-number lot count, for discretizing price levels to the next whole-number tick, and for converting floating-point bar indices or ratio values to conservative integers.
Algorithm
- ▸output[i] = Math.ceil(input[i])
- ▸null inputs → null output
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.
Use Cases
Conservative Lot Sizing
Ceil a fractional contract count to always round up to a whole lot, ensuring you never under-allocate against a target risk budget.
Tick Level Rounding
Ceil a calculated take-profit level to the next integer price, useful when placing orders on assets with whole-number tick sizes.
Period Guard
Ceil a dynamically computed lookback (e.g., volatility-adjusted period) to ensure it is always at least 1 bar.