SOX Fear & Greed Mean Reversion Strategy for thinkorswim

korygill

Well-known member
VIP
Cross-posting here from my twitter and github.

https://github.com/korygill/technical-analysis/blob/master/SOX_FGMR/SOX_FGMR.md

https://twitter.com/korygill/status/1130980985162493952

Using the same techniques as in my other Fear & Greed (FGMR) strategies, I found through some trial and error a strategy for SOX, SOXX, SOXL, SMH that does not fire that often, but has a great win-rate. Although I will point out that win-rate is not everything, capital preservation and small losses and big winners is more important.

NOTE: at this time, us as a long-only strategy. If you find short settings that work, leave a comment and I can update this posting.

P&L look at the strategy

bfymQ6F.png


thinkScript Code
Rich (BB code):
#
# $SOX Fear & Greed Mean Reversion Study (SOX_FGMR)
#
# This script adapted from posts from @kerberos007
# https://twitter.com/kerberos007
# 
# Want the latest version of this script?
# https://github.com/korygill/technical-analysis
#
# Use on thinkorswim and thinkscript
# author @korygill
#

script GetBollingerBandPercent
{
    input price = close;
    input upper = 2;
    input lower = 2;
    input averageType = AverageType.SIMPLE;
    input displace = 0;
    input length = 20;

    def upperBand = BollingerBands(price, displace, length, lower, upper, averageType).UpperBand;
    def lowerBand = BollingerBands(price, displace, length, lower, upper, averageType).LowerBand;

    plot BBPercent = (price - lowerBand) / (upperBand - lowerBand) * 100;
}

input StdDev_DnBuy = -2.5;
input StdDev_UpBuy = 2.5;
input StdDev_DnSell = -1;
input StdDev_UpSell = 1;
input BuyCross = 5;
input SellCross = 95;
input LongShortBoth = {Long, Short, default Both};
input length = 20;
def price = close;
def averageType = AverageType.SIMPLE;
def displace = 0;

def PercentBBuy = GetBollingerBandPercent(price, StdDev_UpBuy, StdDev_DnBuy, length = length);

def PercentBSell = GetBollingerBandPercent(price, StdDev_UpSell, StdDev_DnSell, length = length);

def ZeroLine = 0;
def HalfLine = 50;
def UnitLine = 100;

def lsb;
switch (LongShortBoth)
{
case Long:
    lsb = 0;
case Short:
    lsb = 1;
default:
    lsb = 2;
}

# LONG
AddOrder(OrderType.BUY_TO_OPEN, Crosses(PercentBBuy, BuyCross, CrossingDirection.ABOVE) and lsb != 1, tickcolor = Color.WHITE, arrowcolor = Color.GREEN, name = "XOS");

AddOrder(OrderType.SELL_TO_CLOSE, Crosses(PercentBSell, SellCross, CrossingDirection.ABOVE) and lsb != 1, tickcolor = Color.WHITE, arrowcolor = Color.RED, name = "XOS");

# SHORT
AddOrder(OrderType.SELL_TO_OPEN, Crosses(PercentBBuy, UnitLine, CrossingDirection.BELOW) and lsb != 0, tickcolor = Color.WHITE, arrowcolor = Color.YELLOW, name = "XOS");

AddOrder(OrderType.BUY_TO_CLOSE, Crosses(PercentBSell, ZeroLine, CrossingDirection.BELOW) and lsb != 0, tickcolor = Color.WHITE, arrowcolor = Color.MAGENTA, name = "XOS");

AddLabel(yes, "[SOX:FGMR](1d)", Color.GRAY);
AddLabel(yes, "Go Long", Color.GREEN);
AddLabel(yes, "Cover Long", Color.RED);
AddLabel(yes, "Go Short", Color.YELLOW);
AddLabel(yes, "Cover Short", Color.MAGENTA);

Shareable Link
https://tos.mx/1mbxFb

 

Attachments

  • bfymQ6F.png
    bfymQ6F.png
    119.5 KB · Views: 289
Last edited by a moderator:
Note, as of 5/22/2019, the strategy is currently long 2 units (rare) and at favorable prices.

 
Last edited:
@Koygill, Can you explain what do you mean by long-only strategy and please let us know this will work for all stocks?

 
Last edited:
@San means only trade SOX long with the provided strategy that has settings tuned specifically for SOX. I could not find meaningful values to add to the P&L with short positions. As for other symbols, each one acts a little different and benefits from back testing specific to that symbol. As a general rule, FGMR should apply everywhere and 2.0/-2.0 BB% is a good place to start. See my other FGMR work (which is derived from original works from Kerberos007 on twitter).

 
Last edited:
Can you explain this like I'm 5 or an *****. Which I am. So this signal means buy SOX today? Or as of the day of the signal? Is it still a buy?

 
Last edited:
@Tominatorxx Generally, a good time to buy would be on the day of the signal.

 
Last edited:

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
373 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