Ultimate MACD Indicator for ThinkorSwim

horserider

Well-known member
VIP
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.
 

rcjh88

New member
VIP
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.
 

VicD

Member
https://tos.mx/aCqNr2l I played around a bit.

wAAj06K.png
 

kelvin

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

Code:
# 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;
RSI1.SetDefaultColor(Color.GREEN);
RSI1.SetLineWeight(2);
RSI1.SetStyle(Curve.FIRM);
RSI1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
RSI1.HideBubble();
RSI1.HideTitle();

# RSI2---2nd smoothed RSI---------------------------------------
plot RSI2 = smRSI2;
RSI2.SetDefaultColor(Color.orange);
RSI2.SetLineWeight(2);
RSI2.SetStyle(Curve.FIRM);
RSI2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
RSI2.HideBubble();
RSI2.HideTitle();

#============================================
# 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.SetDefaultColor(Color.red);
BBmidline.SetLineWeight(5);
BBmidline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BBmidline.SetStyle(Curve.FIRM);
BBmidline.HideBubble();
BBmidline.HideTitle();

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;

uBBline.SetDefaultColor(Color.WHITE);
uBBline.SetStyle(Curve.LONG_DASH);
uBBline.SetLineWeight(1);
uBBline.HideBubble();
uBBline.HideTitle();

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

lBBline.SetDefaultColor(Color.WHITE);
lBBline.SetStyle(Curve.LONG_DASH);
lBBline.SetLineWeight(1);
lBBline.HideBubble();
lBBline.HideTitle();

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

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



OB.SetStyle(Curve.FIRM);
OB.SetDefaultColor(Color.red);
OB.SetLineWeight(1);
#OB.HideBubble();
OB.HideTitle();

ML.SetStyle(Curve.LONG_DASH);
ML.SetDefaultColor(Color.WHITE);
ML.SetLineWeight(3);
#ML.HideBubble();
ML.HideTitle();


OS.SetStyle(Curve.FIRM);
OS.SetDefaultColor(Color.LIGHT_GREEN);
OS.SetLineWeight(1);
#OS.HideBubble();
OS.HideTitle();

plot ArrowUp = if RegRSI crosses above lbbline
               then lBBline
               else double.nan;
     ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
     ArrowUP.SetLineWeight(3);
     ArrowUP.SetDefaultColor(Color.White);

plot ArrowDN = if RegRSI crosses below uBBline
               then uBBline
               else double.nan;
     ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
     ArrowDN.SetLineWeight(3);
     ArrowDN.SetDefaultColor(Color.light_GRAY);


#---------------------------------------------------------------------------
# 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?
 

horserider

Well-known member
VIP
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.
 

webdementia

New member
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!!
 

David45

Member
2019 Donor
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!
 

horserider

Well-known member
VIP
@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

Member
2019 Donor
@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!
 

BenTen

Administrative
Staff member
Staff
VIP
@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.

Code:
lower;

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;


Avg.SetDefaultColor(GetColor(8));
 

Learnbot

Active member
@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
 

BenTen

Administrative
Staff member
Staff
VIP
@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.
 

jnuke27

New member
VIP
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:

Similar threads

Top