ICE Data Services -

adx(), pdi(), ndi() Built-in Study Functions

Directional Movement (ADX-DM) indicates the strength of the overall trend. Typically, readings below 20-25 indicate a weak trend. +DI and -DI show the strength of the up trend (+DI) and the strength of the downtrend (-DI), respectively.

Syntax
adx( nLength , nSmoothing [, sym() | inv() ][, nBarIndex ] )
pdi( nLength , nSmoothing [, sym() | inv() ][, nBarIndex ] )
ndi( nLength , nSmoothing [, sym() | inv() ][, nBarIndex ] )

Parameters
Parameter: Description: Default:
nLength Required. Number of periods to use for calculation.

n/a nSmoothing Required. Number of periods to use for calculation.

n/a sym() or
inv()
[Optional]  sym() or inv() to determine symbol/interval source for the study.

Chart's sym/inv nBarIndex [Optional]  Bar index of series to retrieve.

n/a

Return Value(s)

Returns a Series Object when nBarIndex is not specified.

Returns a single value when nBarIndex is specified.

Notes
Only available in versions 7.9 or later.

These built-in study functions do not accept other series objects as the source for the study other than sym() or inv().

Code Examples
Single Line Indicator:
 function main() { return new Array(adx(14, 14), pdi(14, 14), ndi(14, 14) );}

Single Line Study-on-Study Indicator:
 N/A See notes.

Retrieve single values:
 function main() { var nValue_0 = adx(14, 14, 0); // Current Bar Index var nValue_1 = adx(14, 14, -1); // Prior Bar Index return new Array(nValue_0, nValue_1);}

Initialize Series Objects:
 //global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;function main() { if (xStudy1 == null) xStudy1 = adx(14, 14); if (xStudy2 == null) xStudy2 = pdi(14, 14); if (xStudy3 == null) xStudy3 = ndi(14, 14); // retrieve single values for conditional statements var nValue1_0 = xStudy1.getValue(0); // Current Bar Index value var nValue2_0 = xStudy2.getValue(0); // Current Bar Index value var nValue3_0 = xStudy3.getValue(0); // Current Bar Index value var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value // Plot Current Bar Index Value return new Array(nValue1_0, nValue2_0, nValue3_0); }

Initialize a Series Object based on an external interval:
 // global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;var bInit = false; // Initialization flagfunction main() { if (bInit == false) { xStudy1 = adx(14, 14, inv(20)); // 20-min interval xStudy2 = pdi(14, 14, inv(20)); // 20-min interval xStudy3 = ndi(14, 14, inv(20)); // 20-min interval bInit = true; } // retrieve single values for conditional statements var nValue1_0 = xStudy1.getValue(0); // Current Bar Index value var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value // Synchronized Series plot return new Array(getSeries(xStudy1), getSeries(xStudy2), getSeries(xStudy3) ); }

Initialize a Series Object based on an external symbol and interval:
 // global Series Object variablesvar xStudy1 = null;var xStudy2 = null;var xStudy3 = null;var bInit = false; // Initialization flagfunction main() { if (bInit == false) { xStudy1 = adx(14, 14, sym("IBM,20")); // IBM 20-min interval xStudy2 = pdi(14, 14, sym("IBM,20")); // IBM 20-min interval xStudy3 = ndi(14, 14, sym("IBM,20")); // IBM 20-min interval bInit = true; } // retrieve single values for conditional statements var nValue1_0 = xStudy1.getValue(0); // Current Bar Index value var nValue1_1 = xStudy1.getValue(-1); // Prior Bar Index value // Synchronized Series plot return new Array(getSeries(xStudy1), getSeries(xStudy2), getSeries(xStudy3) ); }