Contents
- abs
- add
- all_time_high
- all_time_low
- and
- approx
- aroon_down
- aroon_osc
- aroon_up
- atr
- bb_lower
- bb_upper
- bb_width
- cci
- change
- cond
- count
- cross
- crossover
- crossunder
- cumsum
- days_since
- dev
- deviation
- div
- ema
- eq
- falling
- floordiv
- gain
- gt
- gte
- highest
- highest_bars_ago
- hma
- kc_lower
- kc_middle
- kc_upper
- kcw
- loss
- lowest
- lowest_bars_ago
- lt
- lte
- macd_histogram
- macd_line
- macd_signal
- max
- mean
- median
- mfi
- min
- mod
- mom
- months_since
- mul
- ne
- obv
- offset
- or
- pct_change
- percentrank
- pivothigh
- pivotlow
- pow
- range
- rising
- roc
- rsi
- sma
- sqrt
- stdev
- stoch_d
- stoch_k
- streak
- sub
- sum
- swma
- true_range
- universe_percentile
- variance
- vwma
- weeks_since
- wilderma
- williams_r
- wma
- years_since
No matches
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)