Trading Rush MACD 200 EMA Strategy 62% Win Rate For ThinkOrSwim

Britt95

New member
Good morning traders!

I have been successful paper trading this strategy for some time now and I can actually vouch for it, it’s been profitable for me. I found this strategy on the Trading Rush channel. He’s tested over 50 strategies on Trading View over the years and to this day, the MACD 200 EMA strategy has been #1 in terms of winning percentage. Here is the strategy he came up with:
  • Only long entries above the 200 EMA.
  • Only short entries below the 200 EMA
If criteria is met above…
  • Only long entries if MACD crosses above the signal line from BENEATH the zero line.
  • Only short entries if MACD crosses below the signal line from ABOVE the zero line.

I was able to find the strategy coded on trading view. The source code is public so I pasted it below. I was wondering if anyone can convert the code from pinescript to thinkscript so I can set alerts on thinkorswim?

Below is a picture of the strategy and links for more information:

Picture of Indicator on Trading View Today In Real Time.

Link to his video for a better understanding on the strategy.

Link to the list of strategies he’s tested 100 times.

Source code below:

//@version=4
study(title="Trading Rush Signals & Alerts", shorttitle="Trading RUSH", overlay = true)

trend = input(title="Display 200 EA", type=input.bool, defval=false)
trendma = ema(close, 200)
labeled = input(title="Display strategy name with signals", type=input.bool, defval=true)
indicators = input(title="Display indicators", type=input.bool, defval=false)
plot(trend ? trendma : na, title = "200 EA", color=color.black, linewidth = 3)

////////

// MACD
macdenabler = input(title="Enable MACD ? 🎯", type=input.bool, defval=true)

fast_length = 12 //input(title="Fast Length", type=input.integer, defval=12)
slow_length = 26 //input(title="Slow Length", type=input.integer, defval=26)
srcmacd = close //input(title="Source", type=input.source, defval=close)
signal_length = 9 //input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
// Calculation
fast_ma = ema(srcmacd, fast_length)
slow_ma = ema(srcmacd, slow_length)
macd = fast_ma - slow_ma
signal = ema(macd, signal_length)
hist = macd - signal
//Strategy
buymacd = crossover (macd, signal) and low > trendma and macd[1]<0
sellmacd = crossunder (macd, signal) and high < trendma and macd [1]> 0

plotshape(labeled and macdenabler ? buymacd :na, style = shape.triangleup, size = size.small, location = location.belowbar, color = color.red, title = "MACD Buy L", text = "MACD")
plotshape(labeled and macdenabler ? sellmacd :na, style = shape.triangledown, size = size.small, location = location.abovebar, color = color.red, title = "MACD Sell L", text = "MACD")

plotshape(labeled or not macdenabler ? na : buymacd, style = shape.triangleup, size = size.small, location = location.belowbar, color = color.red, title = "MACD Buy")
plotshape(labeled or not macdenabler ? na : sellmacd, style = shape.triangledown, size = size.small, location = location.abovebar, color = color.red, title = "MACD Sell")

alertcondition(buymacd or sellmacd, title = "MACD Strategy", message = "MACD signal was generated on {{ticker}} at {{timenow}}")
 

Fluideng

Member
Code:
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, close, fastLength) – MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value – Avg;
plot ZeroLine = 0;
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
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”));
ZeroLine.SetDefaultColor(GetColor(0));

# now for the signal
def ValueCrossBelowZeroline = Value[1] < Avg[1] and Value[1] < 0 and Value > Avg;
plot belowZeroCross = if ValueCrossBelowZeroline then Value else Double.NaN;
belowZeroCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
belowZeroCross.SetDefaultColor(Color.CYAN);
def ValueCrossAboveZeroline = Value[1] > Avg[1] and Value[1] > 0 and Value < Avg;
plot aboveZeroCross = if ValueCrossAboveZeroline then Value else Double.NaN;
aboveZeroCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
aboveZeroCross.SetDefaultColor(Color.MAGENTA);

#plot scan = ValueCrossBelowZeroline;
#plot scan = ValueCrossAboveZeroline;
# Alerts
Alert(aboveZeroCross, "ValueCrossAboveZeroline", Alert.Bar, Sound.Bell);
Alert(belowZeroCross, "ValueCrossBelowZeroline", Alert.Bar, Sound.Ding);
 

Fluideng

Member
This is the MACD indicator with Arrows and you can set alerts and scan for the crosses above or below Zero line.
 

Britt95

New member
Great attempt @Fluideng!

However it appears it does not follow the rules of his strategy. The code allows long signals when the price action is below the 200 EMA (suppose to be short) and vice versa.

Also, it's not filtering long entries from beneath the zero line in a long, and above the zero line in a short.

I'm sure this code is pretty complicated, but thank you for the try!!
 

irishgold

Active member
Try This:
Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
input price = close;
input EMAperiod = 200;
plot trendma = ExpAverage(price, EMAperiod);
trendma.SetDefaultColor(Color.Cyan);
def signal = reference MACD(fastLength, slowLength, macdLength, averageType).Avg;
def macd = reference MACD(fastLength, slowLength, macdLength, averageType).Value;
plot buymacd = macd crosses above signal and low > trendma and macd[1] < 0;
buymacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buymacd.setDefaultColor(Color.Green);
plot sellmacd = macd crosses below signal and high < trendma and macd [1] > 0;
sellmacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
sellmacd.setDefaultColor(Color.Red);
 

AshtheMan

New member
@Fluideng I like your signals that come up but I noticed at least for mine the arrows were really on the graph or they looked weird not sure if you made it like that but I am also trying to find an indicator that points the up and down crossovers of the MACD like yours but have another arrow come when the MACD starts to get hit with volume
 

Britt95

New member
AWESOME JOB!!

Thank you so much this makes finding these cross overs so much easier!!

Lastly, I just wanted to know if there was a way to add alerts to this indicator so I wouldn't have to manually watch 10 different stocks?

Thank you again!!!!! @irishgold
 

irishgold

Active member
You would create 2 Scans using the 10 stocks as the basis, then add condition one with plot macdbuy and the second scan plot sellmacd,
once created you create alert based on scan and it can send email or SMS from TOS
 

Fluideng

Member
@Fluideng I like your signals that come up but I noticed at least for mine the arrows were really on the graph or they looked weird not sure if you made it like that but I am also trying to find an indicator that points the up and down crossovers of the MACD like yours but have another arrow come when the MACD starts to get hit with volume
I added volume arrows on the zero line. Not sure about the arrows. Maybe you have to many indicators on your chart.
Code:
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input HighVolume = yes;
input VolumeAveragingLength = 20;
input VolumePercentThreshold = 60;
plot Value = MovingAverage(averageType, close, fastLength) – MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value – Avg;
plot ZeroLine = 0;
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
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”));

##High Volume
def aVol = Average(volume, VolumeAveragingLength);
def pVol = 100 * ((volume - aVol[1]) / aVol[1]);
def pDot = pVol >= VolumePercentThreshold;
def HV= pDot and HighVolume;
plot HiVolArrow = if HV then 0 else Double.NaN;

HiVolArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
HiVolArrow.SetDefaultColor(Color.WHITE);
HiVolArrow.HideTitle();
HiVolArrow.HideBubble();

ZeroLine.SetDefaultColor(GetColor(0));


# now for the signal
def ValueCrossBelowZeroline = Value[1] < Avg[1] and Value[1] < 0 and Value > Avg;
plot belowZeroCross = if ValueCrossBelowZeroline then Value else Double.NaN;
belowZeroCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
belowZeroCross.SetDefaultColor(Color.CYAN);
def ValueCrossAboveZeroline = Value[1] > Avg[1] and Value[1] > 0 and Value < Avg;
plot aboveZeroCross = if ValueCrossAboveZeroline then Value else Double.NaN;
aboveZeroCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
aboveZeroCross.SetDefaultColor(Color.MAGENTA);

#plot scan = ValueCrossBelowZeroline;
#plot scan = ValueCrossAboveZeroline;
# Alerts
Alert(aboveZeroCross, "ValueCrossAboveZeroline", Alert.BAR, Sound.Bell);
Alert(belowZeroCross, "ValueCrossBelowZeroline", Alert.BAR, Sound.Ding);
 

irishgold

Active member
@Britt95 If you don't mind sharing what are your top 10 stocks you are watching?
The problem with Trading Rush testing is it can be a narrow date window even if it was 100 trades, I used his parameters on the NQ with Ninjatrader like he does and from Jan 03 to Sept 03 on 5 min chart it only made $1500 trading Long only. Setting $150 win and $100 stoploss.
Testing on 30 min trading long and short it only made $3200 with a draw down $15,000 with 171 trades, 100 short trades losing -3700 and 71 long trades making 6900. I guess trading Long only 6900 with 71 trades is decent change.
 
Last edited by a moderator:

Britt95

New member
@Britt95 If you don't mind sharing what are your top 10 stocks you are watching?
The problem with Trading Rush testing is it can be a narrow date window even if it was 100 trades, I used his parameters on the NQ with Ninjatrader like he does and from Jan 03 to Sept 03 on 5 min chart it only made $1500 trading Long only. Setting $150 win and $100 stoploss.
Testing on 30 min trading long and short it only made $3200 with a draw down $15,000 with 171 trades, 100 short trades losing -3700 and 71 long trades making 6900. I guess trading Long only 6900 with 71 trades is decent change.
Hey @irishgold!

I trade popular NASDAQ stocks that I am familiar with on the 5-minute chart. AMD, TSLA, AAPL, NVDA, AMZN, BABA, SPOT, MSFT, TQQQ, BYND. I look for basic support and resistance lines and use the trading rush MACD strategy as confirmation. I use a 1:1 and 1:2 risk to reward ratio. If price action achieves 1:1 I take half of trade off and move stop to break even. If price action hits the second profit target I finish the trade with +1.5R. I use this risk management style because it does a better job at protecting against losses. Hope this helps!
 
Last edited by a moderator:

Britt95

New member
After testing out this custom indicator for about a week, I'm starting to believe price action respects VWAP more than the 200 EMA. I've had more winning trades after filtering out potential entries that aren't in trend with VWAP (long above, short below). The data used originally to test this strategy was foreign exchange market. However, I've been using it on stocks and it's worked well for me in the past.

I was wondering if it is possible to use the same strategy and conditions based on VWAP, instead of the 200 EMA?
 

irishgold

Active member
Just remove EMA 200 signal from the plot of the arrows add close > VWAP(Period=AggregationPeriod.DAY), if that's the version of VWAP you are looking at. Whether it works or not will be your judgement after testing.
 

Britt95

New member
Ok great @irishgold, yes I am looking at the daily VWAP. I tried adding the script you mentioned (close > VWAP(Period=AggregationPeriod.DAY) to replace the EMA 200 script but I'm getting an error. I'm attaching the code below.

In line 6, I added "//" to the script to show the original working code that I removed in order to get the VWAP condition to replace the EMA 200.

Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
input price = close;
close > VWAP(Period=AggregationPeriod.DAY) // input EMAperiod = 200;
plot trendma = ExpAverage(price, EMAperiod);
trendma.SetDefaultColor(Color.Cyan);
def signal = reference MACD(fastLength, slowLength, macdLength, averageType).Avg;
def macd = reference MACD(fastLength, slowLength, macdLength, averageType).Value;
plot buymacd = macd crosses above signal and low > trendma and macd[1] < 0;
buymacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buymacd.setDefaultColor(Color.Green);
plot sellmacd = macd crosses below signal and high < trendma and macd [1] > 0;
sellmacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
sellmacd.setDefaultColor(Color.Red);
.
 

irishgold

Active member
Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
input price = close;
input EMAperiod = 200;
plot VWAP1 = VWAP(Period = AggregationPeriod.DAY);

plot trendma = ExpAverage(price, EMAperiod);
trendma.SetDefaultColor(Color.Cyan);
def signal = reference MACD(fastLength, slowLength, macdLength, averageType).Avg;
def macd = reference MACD(fastLength, slowLength, macdLength, averageType).Value;
plot buymacd = macd crosses above signal and close > VWAP1 and macd[1] < 0;
buymacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buymacd.setDefaultColor(Color.Green);
plot sellmacd = macd crosses below signal and close < VWAP1 and macd [1] > 0;
sellmacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
sellmacd.setDefaultColor(Color.Red);
 

QUIKTDR1

Member
VIP
Question??? I added
21:1 AddOrder(OrderType.BUY_AUTO, diff crosses above 0, tickColor = GetColor(0), arrowColor = GetColor(0), name = "MACDStratLE");
22:1 AddOrder(OrderType.SELL_AUTO, diff crosses below 0, tickColor = GetColor(1), arrowColor = GetColor(1), name = "MACDStratSE");

to above MACD_VWAP in order to generate report but received errors
Expected class java.lang.String at 21:1
Expected class java.lang.String at 22:1
No such variable: diff at 21:30
No such variable: diff at 22:31
and tried to change "MACDStratLE" to VWAP1 but was unsuccessful. How best to generate a profit report on study with macd and vwap (replacing 200ema) Please advise!
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@QUIKTDR1
In your AddOrder statement you referenced diff
The error message is saying that there is no definition of diff
You can't reference a name that hasn't been defined.
Add the following statement
def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff ;
 

FuturesTrader7

New member
I decided to make an account today because I was pleased viewing this thread. I use the exact strategy with ETF's and futures, but using a 50 EMA instead of 200. Has been working well for me.

I wanted to know why when I change the input from 200 EMA to 50 EMA it doesn't signal correctly. Does anyone know how to fix this?

Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
input price = close;
input EMAperiod = 50;
plot trendma = ExpAverage(price, EMAperiod);
trendma.SetDefaultColor(Color.Cyan);
def signal = reference MACD(fastLength, slowLength, macdLength, averageType).Avg;
def macd = reference MACD(fastLength, slowLength, macdLength, averageType).Value;
plot buymacd = macd crosses above signal and low > trendma and macd[1] < 0;
buymacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buymacd.setDefaultColor(Color.Green);
plot sellmacd = macd crosses below signal and high < trendma and macd [1] > 0;
sellmacd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
sellmacd.setDefaultColor(Color.Red);

@irishgold @MerryDay
 
Last edited:

FuturesTrader7

New member
Edit: My mistake, I think I see what the issue is, it's taking the signal from the first candle when I enter on the 2nd (so there's no repainting). Can the code be manipulated to show arrows on the 2nd candle open?
Screenshot (133).png

Attached is an example of the indicator not signaling with the 50 EMA.
 
Last edited by a moderator:

irishgold

Active member
within X bars is what you are looking for. So in the BuyMacd there are 3 conditions. So the statement as is will only show an arrow when all 3 conditions hit precisely together. The way around that is add within in 2 bars etc after the condition that you are expecting to be part of the criteria.
So if you want for example the "macd crosses above signal" you would write : macd crosses above signal within 2 bars.
 

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