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
# https://usethinkscript.com/d/193-dmi-directional-movement-index-watchlist-for-thinkorswim
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-"));
Ive been beating my head against the wall on some simple *** issue, and had given up all hope...and then I remembered this site that is full of coding geniuses who are glad to help us dumb shits out with the technicals... pretty straight forward, Im looking to AddCloud to the DMI...green in between when D+ is over D-, and red in between when D+ is under D-... here is what i got so far but Im getting error after error....Thanks a ton to whomever feels generous enough to situate this for me...
Think this is my first post after lurking for a long time. thanks for being here and everything y'all post!
I am trying to clean up and fix whats not working in my below code -
Issues:
1 - When DI+ is above or below Over Sold or Over Bought I have Upsignal and Downsignal arrows, but I Truly only want an arrow when the DI+ is extended beyond the over bought value and reversing lower then the previous closed DI+ value in the last candle to have an arrow, not a bunch of arrows. Vice versa issue for Over bought, I am trying to get only 1 arrow to show when the DI+ is reversing and beyond the Over Sold value line and now reversing higher then the previous DI+ value to have an arrow close in that candle time frame.
2. My chart alerts are not going off when an arrow is showing! If anyone can fix my chart alert code to go off when an arrow is showing, I'd appreciate it.
3. DI+ Bullish and bearish Divergences. I would love to be able to see DI+ Divergences. Bullish Divergence when The stock price having found a previous low, went up and now creating a new lower low, but the DI+ is showing and closing higher then DI+ found at previous low.
Bearish divergences when the stock price had a high, went down, and now creating a new high. It would be nice to see DI+ Divergences when the DI+ is now lower at the new high then what it was when stock price was previous high.
Alot to ask, but I can provide coffee as needed! Thank you so much for even reading this!
I posted my example of divergences to explain myself better in red lines. and my terrible arrows that need help fixing so they dont repeat!
Not sure what you are asking.
Your question is how to print only one arrow? And the one arrow needs to be the last arrow?
Replace your arrow plots with:
Code:
plot UpSignal = if "DI+"[1] crosses above over_Sold and then "DI+" else Double.NaN;
plot DownSignal = if "DI+" crosses below over_bought then "DI+" else Double.NaN;
Hi all,
I am asking if one of you code masters could modify the TOS DMI indicator for me. What I want is a marker (of some sort) on the price chart when the DI+ DI- lines cross. The screenshot gives you an idea of what I am asking for. An alert would be helpful too, but don't want to take advantage of anyone.
Hi all,
I am asking if one of you code masters could modify the TOS DMI indicator for me. What I want is a marker (of some sort) on the price chart when the DI+ DI- lines cross. The screenshot gives you an idea of what I am asking for. An alert would be helpful too, but don't want to take advantage of anyone.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
How do I get started?
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.