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.
Thank you for all the help. Your contributions are truly a blessing!
How do I get the study at the bottom of the chart NicDMI?
Search the “Chart Studies” topic in our Q&A Forum for the term “NicDMI”.
I read the book ADXcellence by Dr. Schaap he has ADX 8, but the DMI+/DMI- of 13. I think its the most useful ADX/DMI book I’ve read. I see that you have length can be set and I would think that would be ADX length. Is there a way to change DMI setting to 13 while keeping ADX as 8??
It is possible but requires rather extensive and complex modifications to the code. Essentially you have to compute both values separately. You can achieve the same result by adding the study twice, applying 8 to the first and turning off the DI plots. Then apply 13 to the second and turn off the ADX plot. Combining this all into a signal chart study or watchlist columns if far beyond the scope of a solution I can provide free of charge.
So i have a question i am trying to implement this alongside with my code for this moving average crossover scanner in order to signify how strong of a move the stock is trending either up or down. This is my code below.. please let me know how can we put two and two together i would kindly appreciate that! Code below is for 13SMA and 30SMA crossover on hourly aggregation.
# Hourly Scan for 13/30 Crossover After 2 Weeks
# Scans for crossovers in both directions
# Choose hourly aggregation – Do NOT include extended hours
# 70 is the number of hourly bars that total two weeks – adjust as desired
input bars_since_cross = 70;
# allows a bit of room to scan for the cross – 7 is within the current day
input max_bars_since_cross = 7;
def ma1 = average(close,13);
def ma2 = average(close,30);
def cross_up = ma1 crosses above ma2;
def cross_dn = ma1 crosses below ma2;
def count_after_cross_up = if cross_up and !cross_up[1] then 1
else count_after_cross_up[1]+1;
def count_after_cross_dn = if cross_dn and !cross_dn[1] then 1
else count_after_cross_dn[1]+1;
def long_entry = count_after_cross_up > bars_since_cross
and cross_dn within max_bars_since_cross bars;
def short_entry = count_after_cross_dn > bars_since_cross
and cross_up within max_bars_since_cross bars;
plot scan = long_entry or short_entry;
# end scan code
I also want to attach a picture of an example of how it would look like when it works but please feel free to shoot me an email: [email protected]
This is well beyond the scope of anything we can address in the comments section of a video. I provide free assistance in the Q&A Forum but this is also well beyond the scope of any solution I can provide free of charge.
I TESTED THIS IN POST MARKET BUT I NOTICED IT IS NOT 100 % ACCURATE. ONLY 70 % TIMES IT SHOWS UP AND DOWN TREND REVERSAL ACCURATELY IN CHART. CAN YOU EXPLAIN WHY? I CHECKED THE EXTENDED HOURS IN STUDY.
THANKS SIR.
So long as you use the same exact settings for the chart as well as the watchlist column everything should match perfectly just as shown in the video.
I am a day trader. I have a watch list I like. I would like to use the conditional wizard to let me know when a stock hits 2 green bars in a 1 minute time frame. I think I have a working knowledge of the conditional wizard.
Could you help me with the code?
Thank You
Dave
Seems you probably intended to post this comment on a different video? This video has nothing to do with the Condition Wizard. That video is located here: https://www.hahn-tech.com/thinkorswim-condition-wizard-watchlist/
If you still need assistance then please take some time to search and browse the many solutions in our Q&A forum. here is a direct link to the Watchlists topic: https://www.hahn-tech.com/ans/cat/watchlists/
Like this tool you have created. The only that I don’t understand is why in some stocks gives me a the message “custom expression subscription limit exceeded”. Why?
Explanation is found in our Q&A forum: https://www.hahn-tech.com/ans/ttm-squeeze-watchlist-column-for-all-nyse-stocks/
I copied ADX script to TOS and the ADX Values in the watch list are different from the values in the TOS charts. Generally the values are higher in TOS
What time frame are you using?
Weekly, daily, and 4 hour. The 4h seems to be off the most. Values for the AUD/CAD currency pair. Watch list = W-25.13 D-15.21 4H-15.56. TOS chart = W-25.17 D-17.25 4H-38.08. TOS 4H chart isshowing a major trend to the upside
There may be a problem with the watchlist in Thinkorswim. Check this post for an example: https://www.hahn-tech.com/ans/percent-relative-strength/
You said there may be a problem with the watch list in TOS and I am not sure what to do next. Is there something I need to do, or is there something you could do to modify the code so the watch list works, or is this an internal problem with TOS. If it is a problem with TOS what do I show them and/or say to them to ID the problem?
What I am saying, and I thought I explained it pretty clear in that post I just linked…. is that the platform is clearly broken right now. Thinkorswim will need to fix this. I have no idea how many different things may be impacted. But it’s clear from the material I present in that post I linked, that something inside is broken. Something we have no control over.
Oh, just noticed you mentioned Forex and we just came across a post in the Q&A forum which addresses inaccuracies when using Forex in a custom watchlist column: https://www.hahn-tech.com/ans/ttm-squeez-watchlist-applied-to-forex/
I followed the instrument like you said on the video
on my watchlist I get the same you have on the video. but on my charts I don’t have the study ADX DMI..am I missing something
The chart study name is DMI. It’s one of the built in studies that come with Thinkorswim. The version I use in the video is a modified version. But the values are identical to the DMI.
Pete, Is there any way to script the ADX for these settings below? These are settings from Trade Station. Trying to see if they can be scripted into TOS. Changes color on the single line as it moves up above or down below the 20 line.
Settings would be Wilders
ADXLength – 14
TriggerLevel – 20
UsePlotColoring – True
AboveTrigColor – Yellow
BelowTrigColor – Red
EqualTrigColor – Cyan
ColorCellBGOnAlert – true
Sure. But the comments section of a video is certainly not the place to be solving requests of this complexity. I suggest you search the Q&A Forum to see if a solution already exists. If you don’t find the answer then post a new question.