High Probability Setup Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
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).

I think this could be useful for your current trading strategy.

Pa0E9KX.png

mufnTVj.png


thinkScript Code

Code:
# High Probability Setup
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/n3o7yet7-UCS-Extreme-Snap-Back-TVI-V2/

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;

## Medium Probability Trade Setup
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:
@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.
 
@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
# Converted from https://www.tradingview.com/script/n3o7yet7-UCS-Extreme-Snap-Back-TVI-V2/

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;

## Low Probability Trade Setup
def ERhigh1 = high > up1;
def ERlow1 = low < dn1;

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

# Medium Probability Trade Setup
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;

# High Probability Trade Setup
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);
 
@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.
 
@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?
 
@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.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
243 Online
Create Post

Similar threads

Similar threads

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