DMI (Directional Movement Index) Watchlist for ThinkorSwim



The DMI indicator (Directional Movement Index) will tell you which direction the price of a stock is moving. When the +DI line is above the -DI line, it means there is more upward movement than downward and vice versa.

The way I use the DMI is a bit different. Instead of using this indicator to tell bullish or bearish trend, I use it as a sideways detector. When the two lines are moving next to each other, it's telling me that the market is choppy at the moment.

Here is an example on the $BYND chart:

The DMI indicator is available right inside ThinkorSwim. You can just add it without additional code. To make things a bit easier on my part, I asked @WalkingBallista if it was possible to make a Watchlist column that displays the range between the DMI lines. The closer they are to each other the more likely that the stock isn't moving anywhere. And of course, he said yes.

Here is the DMI Range watchlist column for anyone interested.

thinkScript Code

Rich (BB code):
# WalkingBallista DMI Range

input length = 14;
input averageType = AverageType.WILDERS;

def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

plot range = AbsValue(AbsValue("DI+")-AbsValue("DI-"));

Shareable Link

Last edited: