Files
QuanTAlib/lib/signals/predicates/isfalling/IsFalling.md
T
Miha Kralj dafc569f4c Add series algebra and signal predicates layer
Series arithmetic (lib/numerics):
- Add, Sub, Mul, Div, Lag, reusing BiInputIndicatorBase at period=1
- Div publishes 0.0 (not NaN) on a zero denominator, since a non-finite
  ComputeError result permanently poisons the base's running sum
- BiInputIndicatorBase gains Subscribe(a, b) implementing the
  strategy-primitives spec's time-join rule for event-chained two-input nodes

Phase 0 contracts (lib/core):
- TTradeContext, BracketFlags, ExitReason, TrendState, VolState
- SignalConstants (DefaultEpsilon, TruthThreshold), OutOfRangePolicy
- ConfirmOnClose: bar-confirmation wrapper (Section 8.6)

Signal predicates (lib/signals/predicates), Phase 1:
- Above, Below, Equal (ComparePredicateBase<TOp> generic comparison core)
- InsideChannel, OutsideChannel, ChannelPosition (new MultiInputBase,
  3-input time-join)
- IsRising, IsFalling (exclude current bar, confirm-then-push window)
- AtHighest, AtLowest (include current bar, rebuild-on-correction,
  mirrors channels/Dc)
- Hysteresis, PercentDistance

All new nodes ship with .cs, tests, and .md docs; indices and the
StrategyPrimitives.Spec.md are updated with placement decisions and
design notes. Full suite: 16730 tests, 0 failures, 0 warnings.
2026-09-25 06:45:03 -07:00

2.4 KiB

ISFALLING: Falling Predicate

The mirror image of IsRising, and just as central to breakdown detection.

Property Value
Category Signals (Predicates)
Inputs Source (single series)
Parameters n (lookback, must be >= 1)
Outputs Single crisp series (IsFalling)
Output range {0.0, 1.0} while hot; NaN during warmup
Warmup n + 1 bars
PineScript ta.falling(source, n)
  • ISFALLING tests whether the current value is strictly less than the minimum of the n bars preceding it.
  • Similar: AtLowest, IsRising | Trading note: The breakdown-below-recent-range test.
  • Part of the strategy-primitives signal algebra.

IsFalling is the exact structural mirror of IsRising: same confirm-then-push window design (a min-tracking MonotonicDeque over confirmed prior bars only, never the currently forming one), same reason no rebuild-on-correction is needed, same warmup and cold-state contract. See IsRising.md for the full implementation rationale, which applies here unchanged with the inequality and deque direction reversed.

Mathematical Foundation


\text{IsFalling}_t(n) = \begin{cases} 1.0 & \text{if } x_t < \min(x_{t-1}, \ldots, x_{t-n}) \\ 0.0 & \text{otherwise} \end{cases}

The window is the previous n bars; a tie is 0.0 (strict comparison).

Validation

Test Status
Warmup returns NaN for the first n bars ✅
n=1: strictly less than the immediately preceding bar ✅
Tie returns false (strict comparison) ✅
Current bar is excluded from its own comparison ✅
Correction to the forming bar does not disturb the confirmed window ✅
Batch/streaming parity ✅

Common Pitfalls

Same as IsRising: the current bar is excluded from its own comparison, this is distinct from AtLowest's inclusive-window question, and warmup is n + 1, not n.

Usage Examples

// "Lower low than the last 5 confirmed bars"
var falling5 = new IsFalling(5);

References

  • TradingView Pine Script Reference: ta.falling.