DI
DI in ProBuilder returns the difference between the DI+ and DI- directional movement lines over N periods, part of the ADX system. Syntax and examples.
Syntax
DI[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 14 | Number of periods for the directional movement calculation. 14 is the standard setting from Wilder's original system. |
price | price source | close | Price argument passed to the calculation, typically close. |
Formula
DI = DIplus[N] - DIminus[N]DIplus and DIminus are the Wilder directional indicators: smoothed positive and negative directional movement, each normalised by the Average True Range and expressed on a 0 to 100 scale.
How it works
The Directional Movement System, introduced by J. Welles Wilder Jr., splits each bar's range extension into upward movement (how much the high exceeded the previous high) and downward movement (how much the low undercut the previous low). After Wilder smoothing and normalisation by the ATR, these become the DI+ and DI- lines.
DI collapses the two lines into a single oscillator by subtracting DI- from DI+. The sign gives trend direction: above zero, upward movement has been stronger over the window; below zero, downward movement has. The magnitude reflects how one-sided the movement is, and a value near zero means buying and selling pressure are roughly balanced.
A zero-line crossing of DI is equivalent to a crossover of the DI+ and DI- lines, so the single-line form is convenient in screeners and strategy conditions where one comparison is simpler than two. Direction alone says nothing about trend strength, which is what ADX measures; the two are usually combined.
Examples
Example 1, Directional balance histogram (Indicator)
// Net directional movement over the last 14 periods
myDI = DI[14](close)
RETURN myDI AS "DI 14"Plots the DI difference as an oscillator around zero. Bars above zero mark periods where upward directional movement dominated, bars below zero the opposite.
Example 2, Trend direction with strength filter (ProOrder)
// Trade DI zero-line crossings only when ADX confirms a trend
direction = DI[14](close)
strength = ADX[14]
IF NOT OnMarket AND strength > 25 THEN
IF direction CROSSES OVER 0 THEN
BUY 1 CONTRACT AT MARKET
ELSIF direction CROSSES UNDER 0 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
ENDIFThe ADX threshold restricts entries to markets that are actually trending, while the sign change of DI picks the direction.
Example 3, Fresh bullish crossovers (ProScreener)
// List instruments where DI+ just overtook DI-
d = DI[14](close)
SCREENER[d CROSSES OVER 0](d AS "DI 14")A positive zero-line cross of DI means DI+ crossed above DI- on this bar, the classic bullish signal of the directional movement system.
Interpretation
- DI above zero. DI+ exceeds DI-, upward price movement has dominated the lookback window. The traditional reading is an uptrend in progress.
- DI below zero. Downward movement dominates, read symmetrically.
- Crossing zero. Equivalent to a DI+/DI- crossover, the basic entry trigger in Wilder's system.
- Magnitude. Larger absolute values mean more one-sided movement. Combined with a rising
ADX, this supports trend-following logic; near zero with a falling ADX, the market is treated as rangebound.
Common errors and gotchas
- Confusing DI with ADX. DI is signed and gives direction. ADX is unsigned and gives strength, being derived from the ratio of the DI difference to the DI sum. Using DI magnitude as a strength filter double-counts direction.
- Whipsaws around zero. In ranging markets DI oscillates tightly around the zero line and produces frequent crossovers. Filter with
ADX, as in Example 2, or require a minimum absolute DI value. - Missing price argument. Unlike
ADX[14], this instruction expects a price argument in parentheses:DI[14](close). Omitting it can raise a syntax error depending on context. - Period mismatches across the system. Mixing
DI[14]withADX[20]produces signals from two different windows. Keep the sameNacross DI, DI+, DI-, and ADX unless the mismatch is intentional.
Related instructions
ADX, trend strength derived from the same directional movement calculations.ADXR, smoothed ADX variant.DIplus, the positive directional indicator on its own.DIminus, the negative directional indicator on its own.AverageTrueRange, the normalising volatility measure inside the DI lines.TR, single-bar true range.VIplus, positive vortex indicator line, a related directional concept.VIminus, negative vortex indicator line.
