Skip to main content

ChartRange

ChartRange defines the bar index and price range of validated signals within a decision tree. When signals in a pattern validate at different bars or prices, ChartRange tracks the combined range so that entries can be placed relative to the validated zone.

Namespace: MZpack.NT8.Algo Inheritance: ChartRange : ICloneable Source: [INSTALL PATH]/API/ChartRange.cs

Properties

PropertyTypeDefaultDescription
BeginSessionIdxint-1Session index when the range started
MinBarIdxint-1Earliest bar index among validated signals
MaxBarIdxint-1Latest bar index among validated signals
Highdouble0Highest price among validated signals
Lowdouble0Lowest price among validated signals

Methods

MethodReturn TypeDescription
Reset()voidReset all values to defaults
AddRange(ChartRange range)voidMerge another range into this range (expand bounds)
GetMaxBarIdx(int idx)intReturn the larger of current max and given index
GetMinBarIdx(int idx)intReturn the smaller of current min and given index
GetMaxHigh(ChartRange range)doubleReturn the higher of two highs
GetMinLow(ChartRange range)doubleReturn the lower of two lows
Clone()objectDeep copy of the range

IRange Interface

IRange defines the constraints for how far apart signals can be (in bars and ticks) and still count as part of the same pattern.

Source: [INSTALL PATH]/API/IRange.cs

PropertyTypeDefaultDescription
Barsint0Maximum bar distance between signals (0 = no limit)
Ticksint0Maximum tick distance between signals (0 = no limit)
LogicLogicAndHow Bars and Ticks constraints combine
IsInSessionboolfalseRestrict range to current session only

When Logic is And, both bar and tick constraints must be satisfied. When Or, either constraint is sufficient.

How It Works

  1. Each SignalsTree has a Range property (IRange) defining the allowed spread between signals
  2. As signals validate, ChartRange accumulates their bar indices and prices
  3. Before the pattern is considered validated, the tree checks that ChartRange fits within the Range constraints
  4. If ChartRange exceeds the range, earlier signals are expired and must re-validate

Exceptions

ExceptionDescription
DecisionTreeSignalChartRangeIsNullExceptionA signal's ChartRange is null when the tree requires range tracking
DecisionTreeSignalChartRangeIsInvalidExceptionA signal's ChartRange has invalid values (e.g. High < Low)

Both extend DecisionTreeException : StrategyException.

Example: Range-Limited Pattern

// Signals must validate within 5 bars and 20 ticks of each other
var range = new Range();
range.Bars = 5;
range.Ticks = 20;
range.Logic = Logic.And;

var pattern = new Pattern(strategy, Logic.And, range,
isShortCircuitANDEvaluation: true);

See Also