MIN
MIN in ProBuilder returns the smaller of two values or variables. Syntax, parameters and examples for capping, clamping and comparing two data series.
Syntax
MIN(a, b)Parameters
| Name | Type | Description |
|---|---|---|
a | number | First value or variable to compare. |
b | number | Second value or variable to compare. |
Formula
MIN(a, b) = a if a <= b, otherwise bThe result equals whichever argument is smaller. When the two are equal, either value is returned since they are identical.
How it works
MIN takes exactly two arguments and returns the lesser. It is the two-value counterpart of Lowest, which scans a single series over a lookback window. To pick the smallest of three or more values, nest calls: MIN(a, MIN(b, c)).
A frequent use is enforcing an upper bound, or cap. MIN(x, k) guarantees the result is never above k. Combined with MAX it clamps a value into a range: MIN(hi, MAX(lo, x)), a pattern used to keep inputs inside a valid domain.
Examples
Example 1, Smaller of two moving averages (Indicator)
// Return whichever low-based average is lower
mmA = Average[20](low)
mmB = Average[50](low)
result = MIN(mmA, mmB)
RETURN result AS "Lower average"MIN picks the lower of the two averages on every bar, producing a lower envelope that tracks whichever period is beneath.
Example 2, Cap a reading at a ceiling (ProScreener)
// Limit an overheated ratio to a maximum of 2
ratio = close / Average[50](close)
capped = MIN(ratio, 2)
SCREENER[ratio > 1](capped AS "Capped ratio")MIN(ratio, 2) prevents extreme values from dominating the scan by holding the reading at a ceiling.
Example 3, Clamp an input into a valid range (ProOrder)
// Keep a normalized reading inside [-1, 1] before using it
raw = (close - Average[20](close)) / (2 * STD[20](close))
clamped = MIN(1, MAX(-1, raw))
IF NOT LongOnMarket AND clamped > 0.8 THEN
BUY 1 CONTRACT AT MARKET
ENDIFPairing MIN with MAX clamps the reading into [-1, 1], which is the safe input range for functions like ASIN and ACOS.
Common errors and gotchas
- Exactly two arguments.
MINcompares two values only. For the lowest across a series useLowest; for three or more values nest calls such asMIN(a, MIN(b, c)). - Not a running minimum.
MIN(a, b)compares the current values ofaandb. It does not track a trough over time. UseLowestfor a rolling low. - Order does not matter.
MIN(a, b)andMIN(b, a)return the same result, so argument order is irrelevant.
Related instructions
MAX, returns the larger of two values, the companion ofMIN.ABS, absolute value, often combined withMINto clamp distances.Lowest, lowest value of a series over a lookback period.Highest, highest value of a series over a lookback period.ROUND, rounds to the nearest integer or decimal.SGN, sign of a value.Range, high-to-low span of a bar.
