Multiple Time Frame DMI Indicator for ThinkorSwim

hinkognito

New member
Hello All,

Could anyone help with generating a MTF DMI Oscillator lower study.

Many Thanks!
 
Last edited by a moderator:
Here ya go:

Code:
declare lower;

input length = 14;
input averageType = AverageType.WILDERS;
input Time2 = AggregationPeriod.FIFTEEN_MIN;
input Time3 = AggregationPeriod.FIVE_MIN;

def hiDiff1 = high - high[1];
def loDiff1 = low[1] - low;

def plusDM1 = if hiDiff1 > loDiff1 and hiDiff1 > 0 then hiDiff1 else 0;
def minusDM1 =  if loDiff1 > hiDiff1 and loDiff1 > 0 then loDiff1 else 0;

def hiDiff2 = high(period = Time2) - high(period=time2)[1];
def loDiff2 = low(period=time2)[1] - low(period=time2);

def plusDM2 = if hiDiff2 > loDiff2 and hiDiff2 > 0 then hiDiff2 else 0;
def minusDM2 =  if loDiff2 > hiDiff2 and loDiff2 > 0 then loDiff2 else 0;

def hiDiff3 = high(period=time3) - high(period=time3)[1];
def loDiff3 = low(period=time3)[1] - low(period=time3);

def plusDM2 = if hiDiff3 > loDiff3 and hiDiff3 > 0 then hiDiff3 else 0;
def minusDM2 =  if loDiff3 > hiDiff3 and loDiff3 > 0 then loDiff3 else 0;

plot osc1 = plusdm1-minusdm1;
plot osc2 = plusdm2-minusdm2;
plot osc3 = plusdm3-minusdm3;
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

hinkognito can you post the final version when you are finished? I am very interested!
Here's one I cooked up a while back
Code:
##################
# MTF DMI ADX
# by PELONSAX
##################

declare lower;

input Agg = AggregationPeriod.THREE_MIN;
input length = 14;
input ADXLength = 14;
input averageType = AverageType.WILDERS;

def hiDiff = high(period = Agg) - high(period = Agg)[1];
def loDiff = low(period = Agg)[1] - low(period = Agg);

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(period = Agg), close(period = Agg), low(period = Agg)), length);
plot "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
plot "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot ADX = MovingAverage(averageType, DX, ADXlength);
plot level25 = 25;

input ShowDI_Plus = yes;
"DI+".SetDefaultColor(Color.GREEN);
"DI+".SetLineWeight(1);
"DI+".SetHiding(!ShowDI_Plus);

input ShowDI_Minus = yes;
"DI-".SetDefaultColor(Color.RED);
"DI-".SetLineWeight(1);
"DI-".SetHiding(!ShowDI_Minus);

input Show_ADX = yes;
ADX.SetDefaultColor(Color.CYAN);
ADX.SetLineWeight(1);
ADX.SetHiding(!Show_ADX);
 
Z37DqX.jpg


Hello guys, I created a DMI MTF indicator that somehow works well on a 5 minute chart. It doesn't repaint, the only thing you need to do is to put the chart to plot 90 days of data. Feel free to check out and add your creativity haha.

Code:
## created by hectorgasm


input ap = AggregationPeriod.DAY;
DEF mthopen = close-close(period = ap)[1];


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

def hiDiff = highest(MTHopen) - highest(MTHopen)[1];
def loDiff = lowest(MTHopen)[1] - lowest(MTHopen);

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(highest(MTHopen), MThopen, lowest(MTHopen)), length);
plot "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
plot "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot ADX = MovingAverage(averageType, DX, length);


plot level = 1;

"DI+".SetDefaultColor(GetColor(1));
"DI-".SetDefaultColor(GetColor(8));
ADX.SetDefaultColor(GetColor(5));
 
Here's one I cooked up a while back
Code:
##################
# MTF DMI ADX
# by PELONSAX
##################

declare lower;

input Agg = AggregationPeriod.THREE_MIN;
input length = 14;
input ADXLength = 14;
input averageType = AverageType.WILDERS;

def hiDiff = high(period = Agg) - high(period = Agg)[1];
def loDiff = low(period = Agg)[1] - low(period = Agg);

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(period = Agg), close(period = Agg), low(period = Agg)), length);
plot "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
plot "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot ADX = MovingAverage(averageType, DX, ADXlength);
plot level25 = 25;

input ShowDI_Plus = yes;
"DI+".SetDefaultColor(Color.GREEN);
"DI+".SetLineWeight(1);
"DI+".SetHiding(!ShowDI_Plus);

input ShowDI_Minus = yes;
"DI-".SetDefaultColor(Color.RED);
"DI-".SetLineWeight(1);
"DI-".SetHiding(!ShowDI_Minus);

input Show_ADX = yes;
ADX.SetDefaultColor(Color.CYAN);
ADX.SetLineWeight(1);
ADX.SetHiding(!Show_ADX);
Thanks Pelonsax! I'm using your MTF ADX with good success.
 
Can you make a multi-frame DMI indicator that uses points instead of lines?

DMI with 2nd aggregation data
can choose to use data from a 2nd aggregation or the chart time
plots points instead of lines

Code:
# dmi_mtf_0a

# DMI
# TD Ameritrade IP Company, Inc. (c) 2008-2022

declare lower;

input prices = { default second_agg, chart };
input agg = AggregationPeriod.HOUR;

def mopen;
def mhigh;
def mlow;
def mclose;
switch (prices) {
case second_agg:
 mopen = open(period = agg);
 mhigh = high(period = agg);
 mlow = low(period = agg);
 mclose = close(period = agg);
case chart:
 mopen = open;
 mhigh = high;
 mlow = low;
 mclose = close;
}


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

#def hiDiff = high - high[1];
#def loDiff = low[1] - low;
def hiDiff = mhigh - mhigh[1];
def loDiff = mlow[1] - mlow;


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 ATR = MovingAverage(averageType, TrueRange(mhigh, mclose, mlow), length);
plot "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
plot "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot ADX = MovingAverage(averageType, DX, length);

"DI+".SetDefaultColor(color.green);
"DI-".SetDefaultColor(color.red);
ADX.SetDefaultColor(color.cyan);

# points
"di+".SetPaintingStrategy(PaintingStrategy.POINTS);
"di-".SetPaintingStrategy(PaintingStrategy.POINTS);
adx.SetPaintingStrategy(PaintingStrategy.POINTS);
"di+".setlineweight(1);
"di-".setlineweight(1);
adx.setlineweight(1);
"di+".hidebubble();
"di-".hidebubble();
adx.hidebubble();
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
182 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

What are the benefits of VIP Membership?
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.
Back
Top