MACD Bullish & Bearish Crossover Watchlist Column for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
This indicator will scan for stocks with bearish and bullish MACD crossover on your watchlist and display it via a column. By default, it will look for crossover within the last 5 bars. You can change the lookback period to your liking in the code below. It works on all timeframe. Be sure to select the timeframe you want when adding the script.

Notes:
  • Orange = Neutral. No crossover within the last X bars
  • Red = Bearish crossover within the last X bars
  • Green = Bullish crossover on MACD within the last X bars


thinkScript Code

Rich (BB code):
# WalkingBallista MACD Lookback Cross
# https://usethinkscript.com/d/191-macd-bullish-bearish-crossover-watchlist-column-for-thinkorswim

declare lower;

input lookback = 5;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

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

def bull_cross = value crosses above avg;
def bear_cross = value crosses below avg;

def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);

plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
signal.AssignValueColor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);

Shareable Link

http://tos.mx/pFX3vh



Credit:
  • @WalkingBallista
 
Last edited:
M

mrmac

New member
VIP
Hi, apologies in advance for what might be a basic question but where do I input the script for this watchlist please? I am pretty new to Thinkorswim so still finding my feet and have created a standard watchlist but the section to open / create this particular option with the MACD crossover script eludes me right now.
Thank you
 
BenTen

BenTen

Administrative
Staff
VIP
@mrmac It's under Watchlist > Customize > Custom Quotes. Select one of the option in there and paste the code in. Also, be sure to adjust the timeframe.
 
M

mrmac

New member
VIP
Thank you very much @BenTen - found it and sorted it. Most appreciated.
 
D

dd1111

New member
so how do we use this in watchlist? we place a trade based on MACD color code?
 
BenTen

BenTen

Administrative
Staff
VIP
@dd1111 That’s one way to blow up your account, for sure. Read up on the MACD indicator and what the crossovers mean before using this watchlist column.
 
K

kshires4

Member
@mrmac It's under Watchlist > Customize > Custom Quotes. Select one of the option in there and paste the code in. Also, be sure to adjust the timeframe.
@BenTen - Where is Watchlist / Customize in TOS. Still cant find it
 
BenTen

BenTen

Administrative
Staff
VIP
@kshires4 Left click on the gear icon and you should see it.

 
S

sobiswas

New member
Is this code portable for the scanner tab? Do a bullish crossover on a timeframe or a bearish one?
 
BenTen

BenTen

Administrative
Staff
VIP
@sobiswas You can setup a scanner for the MACD crossover via the Scan tab. This is only for the watchlist column.
 

Top