MACD scanner in ThinkorSwim

A

Art

Member
Hi Everyone,

I'm new to trading and been papertrading for a few months. I'm a big fan of MACD and DMI and I'm trying to setup a simple MACD scanner. Basically, MACD crosses the 0 line or MACD crosses the DMI-. Sounds simple, but nothing comes up on my scanner. I even changed the time and still nothing. Please, can someone let me know what I'm doing wrong here.

For some reason, I'm not able to post an image. Here are my settings:

Study MACD Crosses Value 0.0 within 1 bars

Thanks in advance,
Art
 
BenTen

BenTen

Administrative
Staff
VIP
There is a setting in the default MACD indicator that lets you turn on breakout signals. Did you try that? If that's what you're looking for, you can use the Scanner with it.
 
horserider

horserider

Well-known member
VIP
@Art ToS has a MACDhistogram crossover standard. Just look in scanner under crossover.

MACD cross -Di ;;;; MACD()."Value" crosses DIMinus() within 3 bars
 
A

Art

Member
Hi Marcos and Ben,

Thanks for your inputs!

Ben, the breakout signal is on, I can see them on my chart. But that's not what I'm trying to do. I want the signal only when the macd crosses 0

Please see what I mean
Marcos, I'm setting up the scanner under a watchlist, however the settings are the same. Actually, I already have several other scanners under my watchlists and they do the work, never used the Hack Scanner. It's only the MACD one that doesn't work. Do you know if the Hack Scanner and ?

Here are my settings


Appreciate your time.
Art
 
9

9ramone7

New member
Can anyone create a scanner that uses the MACD histogram crossover with the settings 12,26,9 and also 3,10,16 on Thinkorswim.
 
BenTen

BenTen

Administrative
Staff
VIP
Just change the input values and you're good to go

 
9

9ramone7

New member
@BenTen of course i've tried this...but both don't work at the same time. I think this could be a very good indicator for intraday trading when both upsignals overlap each other. This worked for me on friday when i tested out the method and allowed me to have a decent green day. But i had to manually find the stocks with both macd settings of 12,26,19 and 3,10,16 upsignals to achieve my profits that day.
 
BenTen

BenTen

Administrative
Staff
VIP
@9ramone7 Can you share some screenshots where both signals overlap with each other?
 
9

9ramone7

New member
@BenTen I don't normally use the one minute time frame to trade due to the noise but mostly the 5 minute. But i noticed a pattern a week ago. Whenever the 12,26,9 MACD settings and the 3,10,16 align with the upsignal. There seems to be a confirmation to buy like no other that i have come across. The reason the 3,10,16 is used is because after reading Tim Sykes comments about the MACD it works well with intraday trading.Here you go. Try this strategy with other stocks that are mainly above the vwap and uptrending and you will see.

 
BenTen

BenTen

Administrative
Staff
VIP
@9ramone7 Here you go, use this with your scanner:

Code:
# Double MACD Signals
# Assembled by BenTen at useThinkScript.com
# Based on the request of 9ramone7

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

input fastLength2 = 3;
input slowLength2 = 10;
input MACDLength2 = 16;

input averageType = AverageType.EXPONENTIAL;

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

def Value2 = MovingAverage(averageType, close, fastLength2) - MovingAverage(averageType, close, slowLength2);
def Avg2 = MovingAverage(averageType, Value, MACDLength2);

def Diff = Value - Avg;
def Diff2 = Value2 - Avg2;
def ZeroLine = 0;

def UpSignal1 = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal1 = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;

def UpSignal2 = if Diff2 crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal2 = if Diff2 crosses below ZeroLine then ZeroLine else Double.NaN;

plot UpSignal = UpSignal1 and UpSignal2;
plot DownSignal = DownSignal1 and DownSignal2;

UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
9

9ramone7

New member
@BenTen you rock man...appreciate you taking the time out of your day to help out the community. It seems like its still missing certain arrows. If you kindly look at the image its missing the upsignal between 11:30AM and 12PM.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@9ramone7 If you zoom in and look closely, I don't think it's on the same candle.
 
9

9ramone7

New member
@BenTen I uploaded another picture for clarity. The upsignals circled in BLUE give the correct overlapping signals for my buy signals.
However, the signals circled in RED apparently is three candles apart even though it gives an upsignal incorrectly.
Then the final one circled in YELLOW is missing the upsignal for some reason

 
Last edited:
J

jpthegreek1

New member
I hope all of you are doing well. I am trying to create a scanner that would look for a change in color on the bars. I can't for the life of me figure out how to make a scan. I believe it would be the Diff but no luck. I would really appreciate some help. Thank you everyone.
 
N

novadolla

New member
How do i turn the below into a dynamic scan? This is actually a default strategy in ToS

input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff;
AddOrder(OrderType.BUY_AUTO, diff crosses above 0, tickColor = GetColor(0), arrowColor = GetColor(0), name = "MACDStratLE");
AddOrder(OrderType.SELL_AUTO, diff crosses below 0, tickColor = GetColor(1), arrowColor = GetColor(1), name = "MACDStratSE");

some one made it into a chart alert at this link below, im looking to create a scan

https://www.hahn-tech.com/ans/generate-alerts-from-macdstrat-chart-strategy/
 
S

serendipity2020

New member
Hello
I'm trying to write scanner using think script which will caclulate daily MACD(12,26,9). Since prices usually always already go higher by the time it crossovers, I was planning to check hourly MACD when daily MACD has not crossed yet. And once hourly MACD crosses then I would get alert via this scanner immediately ahead of daily MACD. So far, I came up with this code below but it doesn't seem to trigger any alerts. I've set it up to run it as hourly so that it will get triggered as soon as hourly MACD crosses signal. Can somoene help in fixing this script?


Code:
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

input averageType = AverageType.EXPONENTIAL;

def DailyMACDValue = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def DailyMACDSignal = MovingAverage(averageType, DailyMACDValue, MACDLength);

def HourlyMACDValue = MovingAverage(averageType, close(period = AggregationPeriod.HOUR), fastLength) - MovingAverage(averageType, close(period = AggregationPeriod.HOUR), slowLength);
def HourlyMACDSignal = MovingAverage(averageType, HourlyMACDValue, MACDLength);

def DailyDiff = DailyMACDValue - DailyMACDSignal;
def HourlyDiff = HourlyMACDValue - HourlyMACDSignal;
def ZeroLine = 0;

def DailyMACDCrossover = if DailyDiff is less than ZeroLine then ZeroLine else Double.NaN;
def HourlyMACDCrossover = if HourlyDiff crosses above ZeroLine then ZeroLine else Double.NaN;

plot UpSignal = DailyMACDCrossover and HourlyMACDCrossover;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
 
BenTen

BenTen

Administrative
Staff
VIP
@serendipity2020 Since the hourly is shorter than the daily timeframe, the crossover will certainly happen on the lower timeframe first. You probably don't need to do anything except scan for the MACD crossover on the hourly chart.
 

Similar threads

Top