The DIplus function is part of the Average Directional Index (ADX) technical indicator, specifically representing the Positive Directional Indicator (+DI). This function is used to measure the strength of an upward price movement and is often used in conjunction with its counterpart, DIminus, to assess the overall trend strength and direction in a market.
DIplus[N](price)
This syntax represents the DIplus function where N is the period over which the indicator is calculated, and price refers to the price type (e.g., close, open, high, low) used in the calculation.
minus = DIminus[14](open)
plus = DIplus[14](open)
IF(minus > plus AND minus[1] < plus[1]) THEN
bull = 1
bear = 0
ENDIF
IF(minus < plus AND minus[1] > plus[1]) THEN
bull = 0
bear = -1
ENDIF
RETURN bull, bear
In this example, the DIplus and DIminus functions are calculated using a 14-period setting based on the ‘open’ price. The script then checks for crossovers between the DIminus and DIplus lines to determine bullish or bearish signals. If DIminus crosses above DIplus from below, it sets a bullish signal (bull = 1, bear = 0). Conversely, if DIminus crosses below DIplus from above, it sets a bearish signal (bull = 0, bear = -1).
This function is essential for traders who utilize technical analysis to make informed decisions based on trend strength and direction.