Directional Indicators

The +DI and -DI measure the strength of the upward and downward price movement to determine the trend direction.

Role in the strategy

SlotAvailableRole
Entry PointNo—
Entry RuleYesFilters entries by the DI+ position against the DI- line.
Exit PointNo—
Exit RuleYesTriggers exits by the DI+ position against the DI- line.

The Directional Indicators produce conditions, not order prices. As an entry rule they are ANDed with the entry point and the other entry rules; as an exit rule they are ORed with the other exit rules. See Indicators for the slot semantics.

Logic rules

RuleLong signal is 1 whenShort signal is 1 when
DI+ line crosses DI- line upwardDI+ crossed above DI-DI+ crossed below DI-
DI+ line crosses DI- line downwardDI+ crossed below DI-DI+ crossed above DI-
DI+ line is higher than DI- lineDI+ is above DI-DI+ is below DI-
DI+ line is lower than DI- lineDI+ is below DI-DI+ is above DI-

The comparison uses the previous bar's values for both lines. DI+ above DI- marks an upward trend, DI- above DI+ a downward trend.

Parameters

ParameterTypeDefaultRangePurpose
Periodnumber101 to 1000Bars of the directional movement smoothing

Calculation

tech.ADX in engine/indicator-engine/tech.ts computes the three lines:

  • DI+ and DI-: exponential averages of the positive and negative directional movement, normalized by the true range.
  • ADX: exponential average of the directional index (drawn for reference).

The ADX, DI+ and DI- lines are drawn in a separate chart pane.

Backtesting

  • The rule is evaluated on the previous (closed) bar with the standard dead zone (SIGMA = 0.000001).
  • The indicator contributes only long/short signal arrays — it never changes the entry or exit order price.
  • An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.