High Probability Setup Indicator for ThinkorSwim

BenTen

BenTen

Administrative
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).

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




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:
J

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

borntostun

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

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
# 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);
 
BenTen

BenTen

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

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

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

BenTen

Administrative
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.
 

Similar threads

Top