Ultimate MACD Indicator for ThinkorSwim

Not much of a scanner user but maybe something like;

MACDstudy()."MACD_Line" is greater than MACDstudy()."MACD_Line" within 3 bars

Where "MACDstudy" is the name you gave the study.

Also try the scanner hacker. Pick study name, pick macd_line,pick greater than or less than and pick the study again and macd_line again.

Not tested, you will need to do that yourself.
Works like a charm. Didn't realize it was so simple. I spent forever trying to change the code and plot where the change occurs and scan for that signal.

Thank you very much.
https://tos.mx/aCqNr2l I played around a bit.

I need help combining the Ultimate MACD indicator with Trader Dynamic Index Indicator.

# LS_TradersDynamIcIndex_long
# Traders Dynamic Index  
# 2 smoothed RSIs Plotted on OverBought / OverSold Grid
# with Bollinger Band of unsmoothed RSIs

declare lower;
input averageType = {default SMA, EMA};

# RSI (Relative Strength Index)====================

input Period = 13;
def RegRSI = reference RSI(Period);

# Compute 2 smoothed (by averaging) RSIs------------------
# 2 Smoothers--------------------------------------------------------
input sm1 = 2; # 1st RSI smoother
input sm2 = 7; # 2nd RSI smoother

# 1st smoothed RSI--------------------------------------------------
# Either ----------------------------------------------------------------
# (1) a simple averaging (SMA) or -------------------------
# (2) an exponential averaging (EMA)---------------------

def smRSI1 = if averageType == averageType.SMA then Average(RegRSI, sm1 ) else ExpAverage(RegRSI, sm1);

# 2nd smoothed RSI------------------------------------------------
# Either ---------------------------------------------------------------
# (1) a simple averaging (SMA) or ---------------------
# (2) an exponential averaging (EMA)-----------------

def smRSI2 = if averageType == averageType.SMA then Average(RegRSI, sm2) else ExpAverage(RegRSI, sm2);

# So far we have:
# 1. RegRSI = RSI
# 2. smRSI1 = 1st smoothed RSI, smoother = 2
# 3. smRSI2 = 2nd smoothed RSI, smoother = 7

# PLOTS---------------------------------------------------------------

# RSI1---1st smoothed RSI----------------------------------------
plot RSI1 = smRSI1;

# RSI2---2nd smoothed RSI---------------------------------------
plot RSI2 = smRSI2;

# Bollinger Bands of RSI=========================

# Length of Bollinger Averaging---------------------------------
input BBlength = 34;          
# Width of Bollinger Band in Standard Deviations----------
input BBsdMult = 1.62;
# Mid-line for the Bollinger Band of the RegRSIs -----------

plot BBmidline = Average(RegRSI, BBlength);

BBmidline.AssignValueColor(if BBmidline < BBmidline [1] then Color.red else (if BBmidline == BBmidline [1] then Color.LIME else Color.LIME));

# Upper and Lower Bollinger Bands---------------------------

# Standard Deviation of unsmoothed RSIs-------------------
def SDBB = StDev(RegRSI, BBlength);

# Upper Line of Bollinger Band----------------------------------
plot uBBline = BBmidline + BBsdMult * SDBB;


# Lower Line of Bollinger Band---------------------------------
plot lBBline = BBmidline - BBsdMult * SDBB;


# GRID-----------------------------------------------------------------

plot OB = 68; # OverBought
plot ML = 50; # Mid-Line
plot OS = 32; # OverSold




plot ArrowUp = if RegRSI crosses above lbbline
               then lBBline
               else double.nan;

plot ArrowDN = if RegRSI crosses below uBBline
               then uBBline
               else double.nan;

# Add Vertical Line when RSI1 crosses BBmidline-----------

#AddVerticalLine (if RSI1 > BBmidline and RSI1[1] <= BBmidline
#then 1 else 0, "--- UP ? ---", Color.lime, Curve.LONG_DASH);

#AddVerticalLine (if RSI1 < BBmidline and RSI1[1] >= BBmidline
#then 1 else 0, "--- DN ? ---", Color.red, Curve.LONG_DASH);

# Cloud between RSI2 and BBmidline-------------------------

AddCloud (RSI2, BBmidline, Color.lime, Color.dark_red);

#def "LL" = if IsNaN(close) then Double.NaN else 55;
#def "HL" = if IsNaN(close) then Double.NaN else 45;

#AddCloud("LL", "HL", Color.cyAN);

# END ======================================

Both indicators come with bollinger band, so can anyone combine them into one indicator to save lower space?
Choose one or the other is my suggestion. Combining would need scaling of one or the other. The RSI 1 line should be very close to the MACD line.
I like this script. Do you have a link back to the original post. I would like to see the thought process behind how it works exactly, Thanks!!
Hi horserider,

I would like to use both your Ultimate MACD and Ultimate RSI together on the same chart to help confirm each other for long and short signals. I see you have a standard, short-term and long-term Ultimate MACD and a short-term and long-term Ultimate RSI.

I will be using these to swing trade index ETFs such as SPY on the daily chart. With that said:

Would you suggest using the short-term or the long-term versions of these studies for my intended purpose? Again, I'm not a day trader, I'm a swing trader using the daily chart for signals.

If using both the Ultimate MACD and Ultimate RSI on the same chart to help confirm each other for long and short signals, would you suggest pairing like time frame versions i.e. the long-term Ultimate MACD with the long-term Ultimate RSI or the short-term Ultimate MACD with the short-term Ultimate RSI? Not sure where the standard Ultimate MACD would fit in with the long-term or short-term Ultimate RSI?

Thanks very much horserider for your insights!
@David45 Pairing short to short or long to long should give confirming signals. This is logical as both are momentum type indicators. So both are giving you the same information. If it works to make money for you then that is all that matters.
Maybe think of combining Long MACD to show bigger trend and the short RSI to pick entry/exit points.
@David45 Pairing short to short or long to long should give confirming signals. This is logical as both are momentum type indicators. So both are giving you the same information. If it works to make money for you then that is all that matters.
Maybe think of combining Long MACD to show bigger trend and the short RSI to pick entry/exit points.
Thank you so much horserider for your thoughts on this. I also really like the idea of using the long-term MACD for the overall trend with the short-term RSI for entry/exit points. Much appreciated!
@bspratt22 It looks like @crawford5002 posted more than what he needed to (probably a mistake). But yes, the following section was not needed otherwise it will show an error in ToS.


input fastLength = 5;
input slowLength = 20;
input MACDLength = 30;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);

def higherFast = Value > Value[1];
def lowerFast = Value < Value[1];
def higherSlow = Avg > Avg[1];
def lowerSlow = Avg < Avg[1];

plot ZeroLine = 0;

@horserider if there a way to make this study an upper study? I don't need the MACD portion as upper but the Bollinger band portion as upper study. i Tried doing it my self but no luck, I tried using TD's bolinger band study but the squeeze seems more pronounced in your study than in TD's Bollinger band. Thank you
@Learnbot BB is of the MACD so it has to be at the lower portion with the MACD indicator. If you just want the bollinger bands of price then use the normal Bollinger Bands indicator provided by ThinkorSwim.
Can someone help me with a scanner that will find tickers that have a color change in the macd line from red to green? I don't need it to be crossing the sma line either. I can't seem to figure out what drives that condition. Thanks in advance.

@rcjh88 - Did you get a scanner to work? I tried "macd_line, pick greater than or less than and pick the study again and macd_line again. " I got no results.
Any luck with this scan technique? I haven't been able to get anything to work that meets the red to green color change criteria on any timeframe.
Last edited by a moderator:

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
354 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.