Custom Watchlist Column Color Coded Based on ADX/DMI Study
The Trend Detector indicator. The DMI (Directional Movement Index) is used by many traders to identify the beginning and direction of trends in the price action. For many years, traders have used multiple time frames to identify opportunities to trade in the direction of the trend. In this video we show how to add three custom columns in a watchlist, one for Weekly, one for Daily and one for Hourly. You can set these to whatever time frames you prefer. Each of the custom columns display all three of the DMI plots. How do we do that? You’ll have to watch the video to find out!
Build your watchlist today
After following our step-by-step instructions you will have your own custom watchlist containing many chart’s worth of information. You will be able to see the position of the DI+ and DI- lines as well as the value of the ADX. All available in a single glance. After setting up the watchlist, we’ll conclude with a demonstration of how to read and interpret the output.
Here is the code you will need to set up your watchlist columns:
input length = 14;
input averageType = AverageType.WILDERS;
input threshold = 20;
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 diPlus = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def diMinus = 100 * MovingAverage(averageType, minusDM, length) / ATR;
def DX = if (diPlus + diMinus > 0) then 100 * AbsValue(diPlus - diMinus) / (diPlus + diMinus) else 0;
# the value of the ADX is shown in the custom column
plot ADX = MovingAverage(averageType, DX, length);
# the colors change based on the postions of various lines to the threshold
# when ADX is below threshold, backgrond is black
# when ADX is above threshold, the background changes based on which di line is on top
# need to have sufficient contrast between color of background and value to ensure it's legible
# try using a white background
# the color of the adx value is green for diPlus > diMinus, otherwise red
ADX.AssignValueColor(if diPlus > diMinus then Color.DARK_GREEN else if diMinus > diPlus then Color.DARK_RED else Color.BLACK);
AssignBackgroundColor(if adx > threshold then Color.WHITE else Color.BLACK);
Learn More:
Click and drag interface to build custom watchlist columns. No code experience required:
Thinkorswim Condition Wizard Watchlist
*Thinkorswim is a chart analysis platform offered by TD Ameritrade: www.tdameritrade.com
TD Ameritrade provides financial services including the trading of Stocks, Futures, Options and Forex.
Please be sure to share this page with your friends and colleagues. Leaving comments below is the best way to help make the content of this site even better.
Hello Pete, is there anyway to assign the following background colors to your original code when these parameters meet?
ADX: is above 20
DM plus: is above DMminus
Assign background color green
or
ADX is above 20
DMminus: is above DMplus
Assign background color Red
thanks
That is possible. However the solution I provided already does that. It just does it using both the background color as well as the color of the value displayed in each sell. I don’t see any point in changing it as you requested.
Thanks for everything you do for viewers. I would like to see % down off 52 WK high, % UP off 52 WK low and % place in 52 WK range in watchlist columns, so that I can sort.
The place to search for solutions like this is in our Q&A Forum. We have an entire topic dedicated to custom watchlist columns: https://www.hahn-tech.com/ans/cat/watchlists/
And if you want to learn how to build your own custom watchlist columns without writing a single line of code be sure to check out the following video: https://www.hahn-tech.com/thinkorswim-condition-wizard-watchlist/