approx

Approximate equality with absolute tolerance

approx(value, target, tolerance)

Parameters

Name Type Description
value field Value to test
target field Target value to compare against
tolerance float Maximum allowed absolute difference (must be non-negative)

Formula

ABS(value - target) <= tolerance

Examples

approx(rsi(close, 14), 50, 2);  // TRUE when RSI is between 48 and 52
approx(close, 100, 0.5);  // TRUE when close is between 99.50 and 100.50
approx(ema(close, 8), ema(close, 21), 0.01);  // TRUE when the two EMAs are within 0.01 of each other

Returns

bool

Notes

For automatic tolerance based on magnitude, use the ~= operator instead (0.1% relative + 1e-9 absolute floor)