Help me write a trend script with RSI and DMI

looking for someone to help me with a script that includes Relative strength index and the directional movement indicator, I'm new to this so bare with me, what I'm looking for is a trend trade indicator that is color coded, with the relative strength index that includes the 15min, 30min, and 1hr at or above the RSI 60 , also including the directional movement indicator at or above 25 to show a bullish move.

Thanks in Advance
 
A few questions:

1. You want an MTF (multi timeframe) version of the RSI indicator?
2. You want to combine the RSI and DMI indicator together?
 
Here is an example scanner. You can get started by clicking on the Scan tab in your ThinkorSwim and add the same conditions below.

acqaTE9.png
 
Here is an example scanner. You can get started by clicking on the Scan tab in your ThinkorSwim and add the same conditions below.

acqaTE9.png
the DMI greater than or equal to 25 on the same timeframes 15 30 1hr to start off, then I will make adjustment if need be, thanks again I just started using thinkorswim so I'm trying to figure this out
 
Shouldn't be a problem but the issue with multi timeframe indicator is that you always have to wait for the candle from the highest timeframe to close in order to confirm the trend direction otherwise you may see fluctuation between signals. I am not sure if you guys are well aware of that.
 
Shouldn't be a problem but the issue with multi timeframe indicator is that you always have to wait for the candle from the highest timeframe to close in order to confirm the trend direction otherwise you may see fluctuation between signals. I am not sure if you guys are well aware of that.
ok understand, how about just the the Trend indicator with the RSI at or above 60 and the DMI at or above 25 for just the time frame you have your chart on, if anything I can watch all 3 time frames
 
Hello,
Is it possible to get the down arrows on top of trend line, and the up arrows below the trend line?
n3ROBoW.png


Here is the code I have

Code:
declare lower;

input length = 7;
input over_Bought = 60;
input over_Sold = 40;
input mid_line = 50;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot MidLine = mid_line;
plot UpSignal = if RSI crosses above RSI[1] then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below RSI[1] then OverBought else Double.NaN;


UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > RSI[1] then color.GREEN else if RSI < RSI[1] then color.RED else color.gray);
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
MidLine.SetDefaultColor(Color.MAGENTA);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
@crawford5002 Just playing around , take a look.
Code:
declare lower;

input length = 14;
input over_Bought = 60;
input over_Sold = 25;
input mid_line = 50;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot MidLine = mid_line;



RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > RSI[5] then color.GREEN else if RSI < RSI[5] then color.RED else color.gray);

##################################################################
input lengthdmi = 14;
input averageTypedmi = 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(averageTypedmi, TrueRange(high, close, low), lengthdmi);
plot "DI+" = 100 * MovingAverage(averageTypedmi, plusDM, lengthdmi) / ATR;


"DI+".AssignValueColor(if "DI+" > 25 then color.LIME else if "DI+" < 25 then color.PINK else color.gray);


plot UpSignal = if RSI >= 60 and "DI+" crosses above 25 then OverSold else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
OverSold.SetDefaultColor(Color.WHITE);
OverBought.SetDefaultColor(Color.WHITE);
MidLine.SetDefaultColor(Color.GRAY);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
 
@crawford5002 Just playing around , take a look.
Code:
declare lower;

input length = 14;
input over_Bought = 60;
input over_Sold = 25;
input mid_line = 50;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot MidLine = mid_line;



RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > RSI[5] then color.GREEN else if RSI < RSI[5] then color.RED else color.gray);

##################################################################
input lengthdmi = 14;
input averageTypedmi = 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(averageTypedmi, TrueRange(high, close, low), lengthdmi);
plot "DI+" = 100 * MovingAverage(averageTypedmi, plusDM, lengthdmi) / ATR;


"DI+".AssignValueColor(if "DI+" > 25 then color.LIME else if "DI+" < 25 then color.PINK else color.gray);


plot UpSignal = if RSI >= 60 and "DI+" crosses above 25 then OverSold else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
OverSold.SetDefaultColor(Color.WHITE);
OverBought.SetDefaultColor(Color.WHITE);
MidLine.SetDefaultColor(Color.GRAY);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Perfect Thank you
 
Shouldn't be a problem but the issue with multi timeframe indicator is that you always have to wait for the candle from the highest timeframe to close in order to confirm the trend direction otherwise you may see fluctuation between signals. I am not sure if you guys are well aware of that.
can help me with labels on the chart showing the 1min RSI 5minRSI and the 15min RSI labels turning green if =60 or greater , yellow if= 50-59, red under 50
 
@crawford5002 You need to adjust the timeframe within the code to 15m. Plus, you can only display data from a higher timeframe onto a lower timeframe.

Example: you can add a label to show 15min RSI on the 5m chart but not the other way around.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
474 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