# High Probability Setup Indicator for ThinkorSwim

#### BenTen

Staff member
Staff
VIP
This is a partial conversion of the original indicator from TradingView called UCS_Extreme Snap Back (TVI) V2. The original version includes three (3) different types of signals: low, medium, and high probability setup. To avoid adding too many signals on the chart, I have decided only to include the high probability trade setup (from the source code).

### thinkScript Code

Code:
``````# High Probability Setup
# Assembled by BenTen at useThinkScript.com

input src = ohlc4;
input len1 = 7;
input len2 = 14;
input len3 = 21;

def tr = Max(close[1], high) - Min(close[1], low);

# Moving Average (Mid Point Fair Value)
def ma1 = simplemovingavg(src, len1);
def ma2 = simplemovingavg(src, len2);
def ma3 = simplemovingavg(src, len3);

# ATR (Dynamic Volatility Units)
def rng1 = simplemovingavg(tr, len1);
def rng2 = simplemovingavg(tr, len2);
def rng3 = simplemovingavg(tr, len3);

# ATR deviation or Secret Sauce of the promoter
def up1 = ma1 + rng1 * 1.6;
def up2 = ma2 + rng2 * 2.4;
def up3 = ma2 + rng3 * 3.2;

def dn1 = ma1 - rng1 * 1.6;
def dn2 = ma2 - rng2 * 2.4;
def dn3 = ma2 - rng2 * 3.2;

def ERhigh3 = high > up1 and high > up2 and high > up3;
def ERlow3 = low < dn1 and low<dn2 and low<dn3;

def HiPERh = if ERhigh3[1] != 1 and ERhigh3 then 1 else 0;
def HiPERl = if ERlow3[1] != 1 and ERlow3 then 1 else 0;

#assignPriceColor(if HiPERh then color.red else if HiPERl then color.green else color.white);

# Plot Signals
plot bullish = HiPERl;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish.SetDefaultColor(Color.CYAN);
bullish.SetLineWeight(1);
plot bearish = HiPERh;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish.SetDefaultColor(Color.MAGENTA);
bearish.SetLineWeight(1);``````

Due to some requests, I have added the additional signals below. The following snippet will add low and medium reversal signals to your chart. All you have to do is paste the following code to the end of your script (from above).

Code:
``````## Low Probability Trade Setup
def ERhigh1 = if high > up1 then 1 else 0;
def ERlow1 = if low <dn1 then 1 else 0;

def ERhigh2 = if high > up1 and high > up2 then 1 else 0;
def ERlow2 = if low < dn1 and low<dn2 then 1 else 0;

def MiPERh = ERhigh2[1] != 1 and ERhigh2;
def MiPERl = ERlow2[1] != 1 and ERlow2;

def LoPERh = ERhigh1[1] != 1 and ERhigh1;
def LoPERl = ERlow1[1] != 1 and ERlow1;

# Plot Extra Signals
plot low_bullish = LoPERl;
low_bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
low_bullish.SetDefaultColor(Color.CYAN);
low_bullish.SetLineWeight(1);
plot low_bearish = LoPERh;
low_bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
low_bearish.SetDefaultColor(Color.MAGENTA);
low_bearish.SetLineWeight(1);

plot medium_bullish = MiPERl;
medium_bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
medium_bullish.SetDefaultColor(Color.CYAN);
medium_bullish.SetLineWeight(1);
plot medium_bearish = MiPERh;
medium_bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
medium_bearish.SetDefaultColor(Color.MAGENTA);
medium_bearish.SetLineWeight(1);``````

Alternatively, you can also use @tomsk modified script below which includes all 3 signals into one script with the option to select which type of signal to display on the chart.

Last edited:

#### john3

##### Active member
2019 Donor
@BenTen, I like it, but would be very interesting to see the other two signals. Would you please include them as an option. If it is too much, they can be commented out. Thank you.

#### borntostun

##### New member
Nice. Going to load this one up for sure this evening. Thanks!

#### tomsk

##### Well-known member
VIP
@BenTen Probably might be an idea to offer the user the choice of input selector whether high, medium or low probability trade setup signals is to be displayed. I've added three input selectors, one for each setup. By default, the high prob setup is enabled is enabled and the other two are set not to display. I've also moved some of the code around to streamline the code logic.

Code:
``````# High Probability Setup
# Assembled by BenTen at useThinkScript.com

input displayLowProb = no;
input displayMedProb = no;
input displayHighProb = yes;

input src = ohlc4;
input len1 = 7;
input len2 = 14;
input len3 = 21;

def tr = Max(close[1], high) - Min(close[1], low);

# Moving Average (Mid Point Fair Value)
def ma1 = simplemovingavg(src, len1);
def ma2 = simplemovingavg(src, len2);
def ma3 = simplemovingavg(src, len3);

# ATR (Dynamic Volatility Units)
def rng1 = simplemovingavg(tr, len1);
def rng2 = simplemovingavg(tr, len2);
def rng3 = simplemovingavg(tr, len3);

# ATR deviation or Secret Sauce of the promoter
def up1 = ma1 + rng1 * 1.6;
def up2 = ma2 + rng2 * 2.4;
def up3 = ma2 + rng3 * 3.2;

def dn1 = ma1 - rng1 * 1.6;
def dn2 = ma2 - rng2 * 2.4;
def dn3 = ma2 - rng2 * 3.2;

def ERhigh1 = high > up1;
def ERlow1 = low < dn1;

def LoPERh = ERhigh1[1] != 1 and ERhigh1;
def LoPERl = ERlow1[1] != 1 and ERlow1;

def ERhigh2 = high > up1 and high > up2;
def ERlow2 = low < dn1 and low < dn2;

def MiPERh = ERhigh2[1] != 1 and ERhigh2;
def MiPERl = ERlow2[1] != 1 and ERlow2;

def ERhigh3 = high > up1 and high > up2 and high > up3;
def ERlow3 = low < dn1 and low<dn2 and low<dn3;

def HiPERh = if ERhigh3[1] != 1 and ERhigh3 then 1 else 0;
def HiPERl = if ERlow3[1] != 1 and ERlow3 then 1 else 0;

#assignPriceColor(if HiPERh then color.red else if HiPERl then color.green else color.white);

# Plot Signals
plot low_bullish = if displayLowProb then LoPERl else Double.NaN;
low_bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
low_bullish.SetDefaultColor(Color.CYAN);
low_bullish.SetLineWeight(1);

plot low_bearish = if displayLowProb then LoPERh else Double.NaN;
low_bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
low_bearish.SetDefaultColor(Color.MAGENTA);
low_bearish.SetLineWeight(1);

plot medium_bullish = if displayMedProb then MiPERl else Double.NaN;
medium_bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
medium_bullish.SetDefaultColor(Color.CYAN);
medium_bullish.SetLineWeight(1);

plot medium_bearish = if displayMedProb then MiPERh else Double.NaN;
medium_bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
medium_bearish.SetDefaultColor(Color.MAGENTA);
medium_bearish.SetLineWeight(1);

plot bullish = if displayHighProb then HiPERl else Double.NaN;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish.SetDefaultColor(Color.CYAN);
bullish.SetLineWeight(1);

plot bearish = if displayHighProb then HiPERh else Double.NaN;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish.SetDefaultColor(Color.MAGENTA);
bearish.SetLineWeight(1);``````

#### BenTen

Staff member
Staff
VIP
@tomsk Thank you so much for that. You’re definitely right. This is much better and cleaner.

#### john3

##### Active member
2019 Donor
@tomsk Thank you very much! One more thing if I may, would you please add actual plots to see what they're doing? Thank you.

#### markos

##### Well-known member
VIP
@tomsk Glad to see you back old friend! I'm not here as much as I should be anymore. Life has gotten in the way. I trust that you and Paris are doing well?

#### BenTen

Staff member
Staff
VIP
@markos Sorry for creating confusion, this post was published long ago in our private Warehouse forum. Today it was moved to the public Indicator forum, and so all the date was changed to the most current.

ty ben

does it repaint?

Staff member
Staff
VIP

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?