MACD with Breakout Signals Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Here is a MACD indicator with breakout signals that shows the beginning of a downtrend or uptrend. For me, the arrows act as a bearish or bullish sign that I sometimes use as buy or sell signals.



thinkScript Code

Rich (BB code):
Archive Name: MACD_withBreakoutSignals_InvTools
Archive Section: Momentum 
Suggested Tos Name: MACD_withBreakoutSignals_InvTools 
Archive Date: 5.13.2018 
Archive Notes:  
"" indicates an addition by the Archivist 

#Number Two MACD with Breakout Signals  [email protected]

declare lower;

input fastLength = 8;

input slowLength = 17;

input MACDLength = 9;

input AverageType = {SMA, default EMA};

plot Diff = MACD(fastLength, slowLength, MACDLength, AverageType).Diff;

Diff.SetDefaultColor(GetColor(5));

Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Diff.SetLineWeight(3);

Diff.DefineColor("Positive and Up", Color.GREEN);

Diff.DefineColor("Positive and Down", Color.DARK_GREEN);

Diff.DefineColor("Negative and Down", Color.RED);

Diff.DefineColor("Negative and Up", Color.DARK_RED);

Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));



plot zeroline = 0;

zeroline.assignValueColor(getcolor(7));



def crossedb = Crosses(diff, 0, CrossingDirection.BELOW);

plot crossbelow = if crossedb then crossedb-1 else double.NaN;

crossbelow.AssignValueColor(getcolor(5));

crossbelow.SetPaintingStrategy(PaintingStrategy.arrow_DOWN);

def crossedu = Crosses(diff, 0, CrossingDirection.above);

plot crossabove = if crossedu then crossedu-1 else double.NaN;

crossabove.AssignValueColor(getcolor(1));

crossabove.SetPaintingStrategy(PaintingStrategy.arrow_up);

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Shareable Link

http://tos.mx/wKPph5
 
Last edited:
R

Rynriggs

New member
@BenTen I’m new to the group and I’m really appreciating yours and everyone else’s thoughts and scripts. Thank you. Let’s make some $$$$$!!!!

 
Last edited:
R

Rynriggs

New member
@Rynriggs



@Rynriggs do you by chance have the Wolfe wave script? Thank you.

 
Last edited:
R

Rynriggs

New member
do you by chance have the script for Wolfe wave?

 
Last edited:
R

Rynriggs

New member
@BenTen do you by chance have the Wolfe wave script? I’ve been looking for it.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@Rynriggs Yes I do. Will post it tonight.

 
Last edited:
J

jimothy

New member
@BenTen is there a way to get the arrows to plot on mobile? or a way to add this to a scanner?
 
BenTen

BenTen

Administrative
Staff
VIP
@jimothy No need to use this one. You can just load up the regular MACD indicator on your mobile app.
 
BenTen

BenTen

Administrative
Staff
VIP
@jimothy Visually different but signals should still be the same. The script above, however, uses different inputs.
 
K

KevinSammy

New member
VIP
@jimothy Visually different but signals should still be the same. The script above, however, uses different inputs.

Hi Ben,

Is there a way to get the arrows to: 1) display on the upper chart and (2) be displayed below the relevant candles?

I tried to update the code to do this, but the arrows plot in various places on the upper chart because they are using the histogram line.

Thank you!
 
BenTen

BenTen

Administrative
Staff
VIP
@KevinSammy There is already an indicator in ThinkorSwim called MACDHistogramCrossover. It does pretty much the same and also plot arrows on your upper chart. You can add it via the Studies section or copy the code below.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2009-2020
#

#wizard input: crossingType
#wizard text: Inputs: fast length:
#wizard input: fastLength
#wizard text: slow length:
#wizard input: slowLength
#wizard text: macd length:
#wizard input: MACDLength
#wizard text: average type:
#wizard input: AverageType

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input crossingType = {default "Positive to Negative", "Negative to Positive"};

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

plot signal = crosses(Diff, 0, crossingType == CrossingType."Negative to Positive");

signal.DefineColor("Negative to Positive", GetColor(2));
signal.DefineColor("Positive to Negative", GetColor(3));
signal.AssignValueColor(if crossingType == CrossingType."Negative to Positive" then signal.color("Negative to Positive") else signal.color("Positive to Negative"));

signal.SetPaintingStrategy(if crossingType == CrossingType."Negative to Positive"
    then PaintingStrategy.BOOLEAN_ARROW_UP
    else PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
T

Trade$$$

New member
@jimothy Visually different but signals should still be the same. The script above, however, uses different inputs.

@BenTen - this script works great for me. Is there a way to convert this into a scan for a watchlist? Thank you for your help and time in advance!
 
Thread starter Similar threads Forum Replies Date
P Remove cloud from MACD custom indicator Questions 1
P Combining EMA and MACD Signals together Questions 5
R Combine MACD and OBV together? Questions 5
I MACD 10x Label? Questions 0
W Mobius MACD Auto-trading Strategy Strategies 10
Top