SOX Fear & Greed Mean Reversion Strategy for thinkorswim


Active member
Cross-posting here from my twitter and github.

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


thinkScript Code
Rich (BB code):
# $SOX Fear & Greed Mean Reversion Study (SOX_FGMR)
# This script adapted from posts from @kerberos007
# Want the latest version of this script?
# 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;
    lsb = 2;

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");

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

Last edited by a moderator:


Active member
Note, as of 5/22/2019, the strategy is currently long 2 units (rare) and at favorable prices.

Last edited:


2019 Donor
@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:


Active member
@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:


New member
Can you explain this like I'm 5 or an idiot. 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:

Similar threads