mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-11-02 07:26:12 +00:00
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.
3.4 KiB
3.4 KiB
OUTSIDECHANNEL: Channel Exclusion Predicate
A breakout, almost by definition, is a value stepping outside a channel it had been living inside.
| Property | Value |
|---|---|
| Category | Signals (Predicates) |
| Inputs | Value, Lower, Upper (triple series, or Value and fixed scalar bounds) |
| Parameters | None |
| Outputs | Single crisp series (OutsideChannel) |
| Output range | {0.0, 1.0} while hot; NaN while cold |
| Warmup | 0 bars (hot after the first tick) |
| PineScript | value > upper or value < lower |
- OUTSIDECHANNEL tests whether a value is above the upper bound or below the lower bound of a channel.
- Similar: InsideChannel, ChannelPosition | Trading note: The direct building block for breakout detection against any channel indicator.
- Part of the strategy-primitives signal algebra.
Mathematical Foundation
\text{OutsideChannel}_t = \begin{cases} 1.0 & \text{if } \text{value}_t > \text{upper}_t \text{ or } \text{value}_t < \text{lower}_t \\ 0.0 & \text{otherwise} \end{cases}
The exact complement of InsideChannel: both use strict inequalities here and inclusive bounds there, so a value sitting exactly on either bound is always inside, never outside, and the two predicates partition every possible input with no overlap and no gap.
Implementation Details
Identical construction to InsideChannel — built on MultiInputBase with 3 inputs (value, lower, upper), same time-join rule, same fixed-scalar-bounds convenience overload for a fixed breakout zone. See InsideChannel.md for the shared implementation rationale.
Performance Profile
| Operation | Count | Notes |
|---|---|---|
| Comparisons | 2 | value > upper, value < lower |
| Sanitize (NaN check) | 3 | One per input |
| Total | ~5 | O(1) constant time |
Validation
| Test | Status |
|---|---|
| Above upper, below lower, and inside bounds | ✅ |
| Boundary values report inside (not outside) | ✅ |
Exact complement of InsideChannel across a range of samples |
✅ |
| Time-join across three independent publishers | ✅ |
| Fixed scalar bounds | ✅ |
Common Pitfalls
- Boundary values are inside, not outside.
OutsideChannelnever fires exactly on a bound; a strategy expecting "touch the band = breakout" should confirm whether it wants this strict definition orNot(InsideChannel(...))with a slightly different epsilon-adjusted bound. - Fires on gaps and spikes, not just sustained breaks. A single-bar wick beyond the channel triggers this predicate the same as a sustained close beyond it; combine with a confirmation trigger (once
signals/triggers/exists) to require persistence.
Usage Examples
// Breakout beyond Donchian Channels
var dc = new Dc(20);
var breakout = new OutsideChannel(price, dc.Lower, dc.Upper);
// Fixed breakout zone
var rsi = new Rsi(14);
var extreme = new OutsideChannel(rsi, 20.0, 80.0);
References
- Murphy, J. (1999). Technical Analysis of the Financial Markets. New York Institute of Finance.