Investment Studio > Expressions > Functions > Indicator > DIM

float array[*][2] dim(float array[*][4] dhlc, integer days = 14, float start_dim = 0)

Returns a two-column array containing dates (first column) and corresponding negative Directional Indicator (-DI) values (second column).

dhlc is a four-column array containing daily price quotes. Each row is structured as follows:

Column # Content
1 The quote date.
2 The day's high (highest traded price).
3 The day's low (lowest traded price).
4 The day's close (last traded price).

The array is assumed to be time-sorted, with earlier dates preceding later dates.

Automatic type conversion allows the use of date strings as arguments instead of explicit date values.

days > 0 is an argument for a built-in EMA (Exponential Moving Average) applied to output values. If omitted, this value defaults to 14.

start_dim is the value returned for the start date (first input date), and the start value for EMA smoothing of all subsequent output values.

Interpretation

-DI is a downside velocity indicator (and the negative component of DI).

Computation of the daily value (days = 1) starts with a comparison of upside and downside price action from the previous day. If the upside dominates (day's high - previous day's high > previous day's low - day's low), the daily value is 0. If the downside dominates (previous day's low - day's low > day's high - previous day's high) the daily value is the downside extension (previous day's low - day's low) divided by the day's True Range (TR).

Since TR is a volatility indicator, this ratio can be seen as a measure of the significance (signal/noise ratio) of price movements on the downside. The larger the daily -DI value, the more bearish the day.

The value for days > 1 is obtained by smoothing daily values with a standard EMA(days) filter. A larger value implies a stronger downside trend over the time frame under study.

-DI is usually plotted together with its upside counterpart, +DI. Signals are triggered by the -DI crossing above the +DI (sell) and by the +DI crossing above the -DI (buy). In trading ranges, this may give rise to whipsaws (quickly negated, false signals). As a way to weed them out, Welles Wilder, the inventor of the directional indicators (New Concepts in Technical Trading Systems, 1978), recommended traders to wait for confirmation of new buy signals in the form of prices rising above the signal day's high, and to wait for confirmation of new sell signals in the form of prices falling below the signal day's low.

For a real life example, consider Cisco (NASD:CSCO) from June 1 to December 31, 2001:

The top chart shows the price, with signals from -DI/+DI crossings highlighted in red (sell) and green (buy). The bottom chart shows the actual ten day -DI (red) and +DI (green) lines, with arrows marking the crossings.

Note how applying Wilder's prescription for buy signal confirmation would have saved us from getting caught by the August 24-28 whipsaw, as well as the two false sell signals in November.

Example

Assuming standard US date format settings,

=dim({{"1/1/1990", 100, 90, 98}, {"1/2/1990", 97, 84, 86}})

returns {{32874, 0}, {32875, 0.0615384615384615}}. 32874 is the date code for January 1, 1990; 0 is the default start_dim value. 32875 is the date code for January 2, 1990; 0.06... is the -DI value for that day, given default start_dim and days argument values.

The bottom chart in the previous section's discussion of NASD:CSCO uses the definitions

_NDAYS = 10

_QUOTES = asset_quotes(SELF, "HLC", FROM_DATE - 2 * _NDAYS, TO_DATE)

_DIM = dim(array(_QUOTES), _NDAYS)

_DIP = dip(array(_QUOTES), _NDAYS)

_CROSSES = crosses(array(_DIP), 2, array(_DIM), 2)

the line sources

vlookup(X, array(_DIM), 2, FALSE)

vlookup(X, array(_DIP), 2, FALSE)

and the image source

choose(2 + vlookup(X, array(_CROSSES), 2, FALSE), {9, vlookup(X, array(_DIP), 2, FALSE), -25}, "", {10, vlookup(X, array(_DIM), 2, FALSE), 25})

The highlighting in the top chart is done with the image source

choose(2 + vlookup(X, array(_CROSSES), 2, FALSE), {12, asset_close(SELF, X)}, "", {13, asset_close(SELF, X)})

See also adxr, aro, asi, atr, di, dip, dm, kb, si, tr, vhf, wad.