Files
QuanTAlib/lib/signals/_index.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

3.0 KiB
Raw Blame History

Signals

Strategy-primitive nodes that turn continuous indicator output into discrete trading logic: predicates, triggers, combinators, and guards, built to a shared value contract (crisp {0, 1}, graded [0, 1], or NaN while cold — see StrategyPrimitives.Spec.md, Section 8.1). Unlike every other category in this library, signals/ is organized into sub-folders because its sub-layers are tightly related and looked up as a group, not because they are independent indicator families.

See StrategyPrimitives.Spec.md for the full design: the layered architecture (predicates → triggers → combinators → guards → position state machine), the value semantics every node here follows, and the phased build plan.

predicates/

Layer 2: stateless-per-bar (or small fixed-window) tests that turn one or more continuous streams into a crisp or graded signal.

Indicator Full Name Description
ABOVE Greater-Than Predicate Crisp: 1.0 when a > b (or a > scalar), else 0.0.
ATHIGHEST At-Maximum Predicate Crisp: 1.0 when the current bar is the max of an n-bar window that includes it.
ATLOWEST At-Minimum Predicate Crisp: 1.0 when the current bar is the min of an n-bar window that includes it.
BELOW Less-Than Predicate Crisp: 1.0 when a < b (or a < scalar), else 0.0.
CHANNELPOSITION Normalized Channel Position Graded [0,1]: (value − lower) / (upper − lower), with an explicit out-of-range policy.
EQUAL Approximate Equality Predicate Crisp: 1.0 when |a − b| ≤ epsilon.
HYSTERESIS Schmitt-Trigger Predicate Crisp latch with a dead band; removes boundary flicker around a threshold.
INSIDECHANNEL Channel Membership Predicate Crisp: 1.0 when lower ≤ value ≤ upper.
ISFALLING Falling Predicate Crisp: 1.0 when current < min(previous n confirmed bars).
ISRISING Rising Predicate Crisp: 1.0 when current > max(previous n confirmed bars).
OUTSIDECHANNEL Channel Exclusion Predicate Crisp: 1.0 when value > upper or value < lower.
PERCENTDISTANCE Relative Distance Raw signed ratio (a − b) / b; feeds Above/Below, not a predicate output itself.

Deferred

  • QuantileRank (P1) — depends on statistics/pctrank, which does not exist yet.

triggers/, combinators/, guards/

Not yet built. See StrategyPrimitives.Spec.md Sections 9.2–9.4 and Section 20 (Phase 1) for the planned contents (CrossOver, BecameTrue, BarsSince, Sequence; AllOf, AnyOf, KOfN, Latch, Inhibit; Cooldown, SessionFilter).