Mean Reversion Strategy - Nick Radge for ThinkorSwim

Zachc

Member
2019 Donor
Nick recently shared a new strategy in his newsletter which you can sign up for here Trade Long Term Registration. This strategy is a Mean Reversion short term trade that seems to work pretty well in longer-term choppy markets. It was developed to complement a long term trend following strategy to smooth out some of the rough points during these sideways markets which trend following strategies have a difficult time in.

Let's dive into the strategy as Nick describes it in his newsletter.

1. Define the upward trend of the stock using a 100-day simple moving average. If the stock is above that average then it's deemed to be bullish.

2. Look for a pullback in that trend using a 2-day RSI. When that falls below 10, the stock is considered heavily oversold.

3. Rank any candidates using Rate of Change and select the top 5. (Not factored into the backtest but should be used if you are trading live)

4. Calculate the Average True Range (ATR) for the prior 10 days. Subtract this from the current low and place a LIMIT buy order at that level for tomorrow.

5. If the LIMIT buy level is met, then await for the first higher close.

6. Exit the position on the following open.

Example Trade

NZcNVDD.png


Back Test and Parameters

20 random securities
20 Years of data
100 shares per trade
10000 Starting Capital

Basic Strategy exit with Higher High Key Stats

I5sis7w.png


P/L and Return Distribution

1PiCEeU.png


I also wanted to see what the effect of just using the RSI Cross under 70 would do and while it did extend the trade time a little longer it introduced a lot of extra volatility into the strategy which invalidates its original purpose.
HIAI4o9.png



Ruby:
## Mean Reversion Strategy - Nick Radge
#Coded in thinkScript by - Zach Corum
#Coded for the useThinkscript community www.usethinkscript.com

#Basic Guide
#When a stock is trending higher look for a heavily oversold point. Once an oversold level is #attained, place a buy order below the market for the following day. If that order is filled, await #the first higher close then exit the position on the next open.


input PortfolioSize = 10000;
input TradeSizePct = .05;
input TurnOnPsize = {default "Off", "On"};
input size = 100;
input MovingAverage = 100;
input ExitStrat = {default "Next Higher Close", "RSI Cross"};
input RSIl = 2;
input RSIOver = 10;
input ATRl = 10;

#Position Sizing
def pSize = PortfolioSize;
def sizeP = PortfolioSize * TradeSizePct;
def tSize = If (TurnOnPsize, sizeP / open[-1], size);

def bullbear = SimpleMovingAvg(length = MovingAverage) < close;
def pullBack = RSI(length = RSIl, "over sold" = RSIOver);
def ATR = close - ATR(ATRl);
def ATRentry = ATR >= low[-1] and ATR <= high[-1];

plot entry = pullBack < RSIOver and bullbear and ATRentry ;
plot CloseHigh = !entry[1] and close > close[1] and close > close[2];
plot movAvg = SimpleMovingAvg(length = MovingAverage);
plot exit = If (ExitStrat, pullBack crosses below RSI(2).overbought, !entry and CloseHigh);
#plot exit = RSI(length = 2, "over bought" = 70) crosses below 70;

entry.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_POINTS);
entry.SetLineWeight(4);
entry.SetDefaultColor(color = Color.BLUE);
Closehigh.SetPaintingStrategy(paintingStrategy = PaintingStrategy.BOOLEAN_ARROW_DOWN);
Closehigh.SetLineWeight(4);
Closehigh.SetDefaultColor(color = Color.LIME);

AddOrder(OrderType.BUY_TO_OPEN, entry and bullbear, ATR, tSize, tickcolor = Color.DARK_ORANGE, arrowcolor = Color.DARK_ORANGE);
AddOrder(type = OrderType.SELL_TO_CLOSE, exit, tickcolor = Color.GRAY, arrowcolor = Color.GRAY, name = "LongEX");
 

Attachments

  • NZcNVDD.png
    NZcNVDD.png
    118.3 KB · Views: 314
  • I5sis7w.png
    I5sis7w.png
    62.2 KB · Views: 245
  • 1PiCEeU.png
    1PiCEeU.png
    45.3 KB · Views: 234
  • HIAI4o9.png
    HIAI4o9.png
    12.6 KB · Views: 312
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Bug
Ruby:
plot CloseHigh = close > close[1] and close > close[2];

There was a possibility for a close signal to be on the same candle as an order entry which would close you out of the trade the day after entry.
To mitigate that I changed the line above and moved it below plot entry

New Code
Ruby:
plot CloseHigh = !entry[1] and close > close[1] and close > close[2];
 
GReat job @Zachc I was testing this strategy myself manually after I saw it on the newsletter. It seemed fitting to the market behavior a few months back. I suppose now it would not be the right approach (back to Bollinger bands breakout or the Weekened trend trader).
I wonder what kind of filter for volatility (ex: VIX highe ro rlower than 15) could be used to decide on which strategy to make dominant...

BTW what platform are you using for your backtests, i see the report and chart is excel but do you use a sw platform for running the simulations?
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
216 Online
Create Post

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