TOP Ultimate Breakout Indicator for ThinkorSwim

@MatthewTherrien They are simply failed breakouts. Start off in a downtrend, then reverse. Getting rid of the HA candles and perhaps the super trend if you're using it will let you see price action better. It's def not all uptrend there.
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

@Thomas, thanks for sharing. I understand the MACDs as a relation midterm (weekly) to long-term (monthly) comparison.

How do you use this?
The MACD MTF I shared takes the place of your MACD and maybe one other indicator that lags to free up real estate and a more confident picture, only suggestion......
 
Back testing will make sense but when testing it live it will cause u to enter at wrong spot and more drop can happen.

This indicator is good we need to find best way to eliminate the bad signals.
 
Last edited by a moderator:
In my testing, this RSI + EMA lower indicator actually gives a lot of false signals. I just witnessed the EMAs riding your sell signal and bouncing on and off it for hours during an uptrend.
 
So what I am thinking is that I want to cut down on false signals from UBI. Therefore I would think the other indicators need to be leading the UBI. Not sure how that will work on continuations? Perhaps maybe they have to be in confluence within a certain number of bars(maybe adjustable use interface) that way it can be adjusted for volatility.
I developed a system of rules involving moving averages that significantly reduce the false signals from the Top indicator by more than 50%. Sometimes all losing trades are eliminated depending on the day.

These rules are for long trades so just do the opposite for shorts:

1 minute chart

General entry rules:
Enter when a candle breaks above first candle to close above Top indicator signal line. First candle to close must be equal to or greater than the 1 minute ATR. If smaller than ATR, Enter at break of 2nd bullish candle (must be at least ATR). Stop loss just below Top signal line.

False signal elimination rules:
Do not enter if VWAP or 200ma is close above entry point - strong resistance

If VWAP/200ma is just above indicator, wait for break and possibly retest as support before entry

Do not enter on first signal after 9 and 20 EMAs cross below 50ma or 200ma. Wait for at least the second signal.

Do not enter on first signal after a strong down move – allow consolidation, wait for at least the second signal.

Do not enter countertrend if price is holding moving averages – usually holds EMAs, then breaks to 50ma, then breaks out.
 
I was able to rip out the Switch/Case statements and reassemble this without disturbing the logic (I think).

Would appreciate if you guys can take a look and see if I have missed/messed something :)

Below is the image of what the study looked like with /ES today on the 5min


Image link


Code:
#V 1.0 5/5 
# Top Ultimate Breakout Indicator
# tomsk
# 1.22.2020

# V1.0 - 12.08.2019 - hoojsn - Initial release of Top Ultimate Breakout Indicator (syntax errors)
# V1.1 - 12.08.2019 - tomsk  - Cleared all syntax errors from initial hoojsn release
# V1.2 - 12.31.2019 - tomsk  - Removed all extraneous logic and variables not used by the study
# V1.3 - 01.02.2020 - tomsk  - Added ShowTodayOnly input selector to display current intraday levels
# V1.4 - 01.16.2020 - tomsk  - Added ShowEntryExitBands input selector, can be set to "no"
# v1.5 - 01.22.2020 - tomsk  - Added ShowBubbles input selector, to toggle display of bubbles

## Added supertrend - RCONNER7 03.30.2020 ##

## Converted to long/short in the same study - BabajiKaThullu 5/9/2022
    # Added lables for MACD 5/8/3 and 13/21/8 based on recomendation from Samoya in post 274 here https://usethinkscript.com/threads/top-ultimate-breakout-indicator-for-thinkorswim.1243/post-48327

# http://www.coinerpals.com/download-top-trade-tools-top-ultimate-breakout/
# https://bestforexfeatured.com/product/toptradetools-ultimate-breakout/


#Inputs 
input BuyorSell = {default Buy, Sell};
input ShowTodayOnly = yes;
input ShowEntryExitBands = yes;
input ShowBubbles = yes;
input BuyEntry = 3;
input SellEntry = 3;
input BuyExit = 20;
input SellExit = 20;
input UseMACDfilter = yes; # conditions MACD 5/8/3 Fast line crosses Zero line and MACD 13/21/8 Fast line crosses slow line
input fastLength_one = 5;
input slowLength_one = 8;
input MACDLength_one = 3;
input averageType_one = AverageType.EXPONENTIAL;
input fastLength_two = 13;
input slowLength_two = 21;
input MACDLength_two = 8;
input averageType_two = AverageType.EXPONENTIAL;

input ATRLength = 50;
input TargetATRMult = 1;
input DisplayLines = yes;
input PriceDigit = 2;
#input OpenTime = 0940;
#input CloseTime = 1550;
#input notrades = 1550;
#def OpenGood = SecondsFromTime(OpenTime) >= 0 and SecondstillTime(notrades) >= 0;
#def CloseAllCondition = SecondstillTime(CloseTime) == 0;

def today = !showTodayOnly or getDay() == getLastDay() and SecondsFromTime(0930) >= 0;

# SuperTrend - YAHOO Finance ver.
input AtrMult = 1.2;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;


#Conditions setup
def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (AtrMult * ATR);

def LW_Band_Basic = HL2 + (-AtrMult * ATR);

def UP_Band = if ((UP_Band_Basic < UP_Band[1]) or (close[1] > UP_Band[1])) then UP_Band_Basic else UP_Band[1];

def LW_Band = if ((LW_Band_Basic > LW_Band[1]) or (close[1] < LW_Band[1])) then LW_Band_Basic else LW_Band[1];

def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band else if ((ST[1] == UP_Band[1]) and (close > Up_Band)) then LW_Band else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band else LW_Band;

def ST_UP = ST < close;
def ST_DN = ST > close;

# High

def H1  = Highest(high, SellExit);
def H2  = fold i = 1 to SellExit
          with ip = 0.0
          do if GetValue(high, i) == H1 or GetValue(high, i) < ip
             then ip
             else GetValue(high, i);
def H3  = fold i1 = 1 to SellExit
          with ip1 = 0.0
          do if GetValue(high, i1) == H1 or GetValue(high, i1) == H2 or GetValue(high, i1) < ip1
             then ip1
             else GetValue(high, i1);
def HH  = (H2 + H3) / 2.0;

# Low

def L1  = Lowest(low, BuyExit);
def L2  = fold i2 = 1 to BuyExit
          with ip2 = 10000000.0
          do if GetValue(low, i2) == L1 or GetValue(low, i2) > ip2
             then ip2
             else GetValue(low, i2);
def L3  = Lowest(if low == L1 or low == L2 then 1000000 else low, BuyExit);
def LL  = (L2 + L2) / 2.0;

def QB = Highest(high, BuyEntry);
def QS = Lowest(low, SellEntry);

def ATRVal = ATR(length = ATRLength, averageType= AverageType.SIMPLE);
def mATR = Highest(ATRVal, ATRLength);


###############################
# MACD filter setup

# First MACD group
def FastMA_one = MovingAverage(averageType_one, close, fastLength_one);
def SlowMA_one = MovingAverage(averageType_one, close, slowLength_one);

def Value_one = MovingAverage(averageType_one, close, fastLength_one) - MovingAverage(averageType_one, close, slowLength_one);
def Avg_one = MovingAverage(averageType_one, Value_one, MACDLength_one);

plot Diff_one = Value_one - Avg_one;
Diff_one.Hide();
AddLabel(yes, "MACD 5/8/3: "+ Value_one +" "+ if Value_one[1] < Value_one then "Up" else "Down", if Value_one >= 0  then Color.GREEN else Color.RED);


# Second MACD group
def FastMA_two = MovingAverage(averageType_two, close, fastLength_two);
def SlowMA_two = MovingAverage(averageType_two, close, slowLength_two);

def Value_two = MovingAverage(averageType_two, close, fastLength_two) - MovingAverage(averageType_two, close, slowLength_two);
def Avg_two = MovingAverage(averageType_two, Value_two, MACDLength_two);

plot Diff_two = Value_two - Avg_two;
Diff_two.Hide();
AddLabel(yes, "MACD 13/21/8: " + Diff_two + " " + if Diff_two[1] < Diff_two then "Up" else "Down", if Value_two > Avg_two then Color.GREEN else Color.RED);

def MACD_bull = if useMACDfilter and Value_one > 0 and Diff_two > 0 then yes else no;
def MACD_bear = if useMACDfilter and Value_one <= 0 and Diff_two <= 0 then yes else no;
AddLabel(yes, MACD_bull +" "+ MACD_bear, Color.YELLOW);


###############################################
# Buy side setup 


#plot long_Entry;
#plot long_Exit;

#def long_EntryPr;
#def long_pos;
def co = BarNumber() > Max(SellExit, BuyExit);  

#switch (BuyorSell) {

#case Buy:
plot long_entry = QB[1];
long_entry.hide();
plot long_exit = LL[1];
def long_pos = if ST_UP and co and high > QB[1] then 1 else if low < LL[1] then 0 else long_pos[1];
def long_EntryPr = if high > QB[1] and long_pos == 1 and long_pos[1] < 1
              then QB[1]
              else if long_pos == 0
                  then Double.NaN
              else long_EntryPr[1];
              
long_entry.AssignValueColor(Color.light_GREEN);
long_entry.setstyle(curve.short_DASH);
long_entry.setlineWeight(2);
long_entry.SetHiding(!ShowEntryExitBands);
long_exit.SetDefaultColor(Color.green);
long_exit.setstyle(curve.short_DASH);
long_exit.setlineWeight(2);
long_exit.SetHiding(!ShowEntryExitBands);
              
#case Sell:
#plot short_Entry;
#plot short_Exit;

#def short_EntryPr;
#def short_pos;

plot short_entry = QS[1];
short_entry.hide();
plot short_exit = HH[1];
def short_pos = if ST_DN and co and low < QS[1] then -1 else if high[1] > HH[2] then 0 else short_pos[1];
def short_EntryPr = if low < QS[1] and short_pos == -1 and short_pos[1] > -1
              then QS[1]
              else if short_pos == 0
                  then Double.NaN
              else short_EntryPr[1];
#}
short_entry.AssignValueColor(Color.light_red);
short_entry.setstyle(curve.short_DASH);
short_entry.setlineWeight(2);
short_entry.SetHiding(!ShowEntryExitBands);
short_exit.SetDefaultColor(Color.red);
short_exit.setstyle(curve.short_DASH);
short_exit.setlineWeight(2);
short_exit.SetHiding(!ShowEntryExitBands);

#def BTarget;
#def BTarget2;
#def EntryLine;
#def TradeRisk;

#switch (BuyorSell) {

#case Buy:
def long_BTarget  = if long_pos == 1 and long_pos[1] < 1
                   then (long_EntryPr + (TargetATRMult * 2 * mATR))
               else if long_pos == 1
                   then long_BTarget[1]
               else Double.NaN;
def long_BTarget2 = if long_pos == 1 and long_pos[1] < 1
                   then (long_EntryPr + 2 * (TargetATRMult * 2 * mATR))
               else if long_pos == 1
                   then long_BTarget2[1]
               else Double.NaN;
def long_EntryLine = if LL < long_EntryPr then long_EntryPr else Double.NaN;
def long_TradeRisk = (long_EntryPr - LL) / mATR;

plot long_pBTarget = if today and DisplayLines and co then long_BTarget else Double.NaN;
long_pBTarget.SetDefaultColor(Color.LIGHT_GREEN);

plot long_pBTarget2 = if today and DisplayLines and co then long_BTarget2 else Double.NaN;
long_pBTarget2.SetDefaultColor(Color.LIGHT_GREEN);

plot long_pEntryLine = if today and DisplayLines and co then long_EntryLine else Double.NaN;
long_pEntryLine.SetDefaultColor(Color.LIGHT_GREEN);

def long_valco = DisplayLines and co and (long_pos == 1 or long_pos == -1) and long_pos[1] == 0;
def long_rBTarget = Round(long_BTarget, PriceDigit);
def long_rBTarget2 = Round(long_BTarget2, PriceDigit);
def long_rEntryPr = Round(long_EntryPr, PriceDigit);

AddChartBubble(ShowBubbles and today and long_valco, long_BTarget, long_rBTarget, Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and today and long_valco, long_BTarget2, long_rBTarget2, Color.LIGHT_GREEN);
AddChartBubble(ShowBubbles and today and long_valco, long_EntryPr, long_rEntryPr, Color.LIGHT_GREEN);

def long_exv = LL;
def rlong_exv = Round(long_exv, PriceDigit);
def rlong_TradeRisk = Round(long_TradeRisk, PriceDigit);

AddChartBubble(ShowBubbles and today and long_valco, long_exv, rlong_exv + "(" + rlong_TradeRisk + "ATR)", Color.GREEN);



########################################
#Short side setup 

#case Sell:
def short_BTarget  = if short_pos == -1 and short_pos[1] > -1
                   then (short_EntryPr - (TargetATRMult * 2 * mATR))
               else if short_pos == -1
                   then short_BTarget[1]
               else Double.NaN;
def short_BTarget2 = if short_pos == -1 and short_pos[1] > -1
                   then (short_EntryPr - 2 * (TargetATRMult * 2 * mATR))
               else if short_pos == -1
                   then short_BTarget2[1]
               else Double.NaN;
def short_EntryLine = if HH > short_EntryPr then short_EntryPr else Double.NaN;
def short_TradeRisk = (HH - short_EntryPr ) / mATR;
#}

plot short_pBTarget = if today and DisplayLines and co then short_BTarget else Double.NaN;
short_pBTarget.SetDefaultColor(Color.LIGHT_RED);

plot short_pBTarget2 = if today and DisplayLines and co then short_BTarget2 else Double.NaN;
short_pBTarget2.SetDefaultColor(Color.LIGHT_RED);

plot short_pEntryLine = if today and DisplayLines and co then short_EntryLine else Double.NaN;
short_pEntryLine.SetDefaultColor(Color.LIGHT_RED);

def short_valco = DisplayLines and co and (short_pos == 1 or short_pos == -1) and short_pos[1] == 0;
def short_rBTarget = Round(short_BTarget, PriceDigit);
def short_rBTarget2 = Round(short_BTarget2, PriceDigit);
def short_rEntryPr = Round(short_EntryPr, PriceDigit);


AddChartBubble(ShowBubbles and today and short_valco, short_BTarget, short_rBTarget, Color.LIGHT_RED);
AddChartBubble(ShowBubbles and today and short_valco, short_BTarget2, short_rBTarget2, Color.LIGHT_RED);
AddChartBubble(ShowBubbles and today and short_valco, short_EntryPr, short_rEntryPr, Color.LIGHT_RED);


def short_exv = HH;
def rshort_exv = Round(short_exv, PriceDigit);
def rshort_TradeRisk = Round(short_TradeRisk, PriceDigit);

AddChartBubble(ShowBubbles and today and short_valco, short_exv, rshort_exv + "(" + rshort_TradeRisk + "ATR)", Color.RED);
# End Top Ultimate Breakout Indicator


Here is the direct link to the study: https://tos.mx/6B0Tcib (updated)

Let me know if this helps or if you face any issues....

/Baba

The above is still a WIP so the code still looks ugly with bunch lines of code that need to be taken out...

@spartan.ts is this what you were looking for ?

/Baba
 
Last edited:
The above is still a WIP so the code still looks ugly with bunch lines of code that need to be taken out...

@spartan.ts is this what you were looking for ?

/Baba
Hey Baba, thanks for taking the time. Well executed! this is what i was thinking. I noticed you removed the exit atr line.
Also, it appears that you are using the ATR as the condition for buy/sell signals? Although this works well, the thought was to use a 50 ema (price above vs price below) to determine direction. thoughts?

thanks.
 
Hey Baba, thanks for taking the time. Well executed! this is what i was thinking. I noticed you removed the exit atr line.
Also, it appears that you are using the ATR as the condition for buy/sell signals? Although this works well, the thought was to use a 50 ema (price above vs price below) to determine direction. thoughts?

thanks.
I have added the long and short exits back. Updated the code and the link above.

If you want you can activate the entry lines also from study customization. The exit lines are dashed to differentiate which can also be changed if you like from the study customization.

You can add any number of indicators to determine trend and if you like to use the 50ema then go for it.


/Baba
 
I have added the long and short exits back. Updated the code and the link above.

If you want you can activate the entry lines also from study customization. The exit lines are dashed to differentiate which can also be changed if you like from the study customization.

You can add any number of indicators to determine trend and if you like to use the 50ema then go for it.


/Baba
Thanks.
Part of the reason to code in the condition filter is to not have the chart too cluttered. Will see what i can manage. thank you again.
 
@Chence27 Your entry settings with 3 are fine and the best settings to use.

Here are my other settings.

View attachment 8920[/IMG]

Your SL is fine. You have to be comfortable with it. I like to use a fixed $ amount according to the SL line and to calculate how many contracts I can trade. The micros offer a lot flexibility. I think we have a nice setup here. Try some additional indicator to valuate the entries better.

HAPPY NEW YEAR :)
Samoya you posted a double macd strategy you used for top ultimate breakout indicator. What are the settings for the two macds.
 
Last edited by a moderator:
Hi @samer800 , Would it be too much trouble to ask if you can incorporate the WinRate/P&L Labels you developed for this script (Ranges with Targets) into this one?

I tried, but something doesn't seem accurate in calculations / backtest result. would appreciate it if you can review it. thanks.


Code:
def entry;
def win;
def los;
def profit;
def losses;
def TP;
def SL;
input share = 100;
def LongTrade ;
def ShortTrade ;

def Long  = BUY  and !TradeisON[1];
def Short = SELL and !TradeisON[1];

if Long and !TradeisON[1] {
    LongTrade = yes;
    ShortTrade = no;
} else
if Short and !TradeisON[1] {
    LongTrade = no;
    ShortTrade = yes;
} else {
    LongTrade = LongTrade[1];
    ShortTrade = ShortTrade[1];
}
def bar_index = AbsValue(BarNumber());
if  long_pos == 1 and long_pos[1] < 1  {  #and !short_pos
    entry = long_EntryPr;
    TP = long_BTarget1;
    SL =   long_stop;
    win = if Bar_index < 1 then 0 else win[1];
    los = if Bar_index < 1 then 0 else los[1];
    profit = if Bar_index < 1 then 0 else profit[1];
    losses = if Bar_index < 1 then 0 else losses[1];
    TradeisON = yes;
} else
if  short_pos == -1 and short_pos[1] > -1  { # and !long_pos
    entry = short_entryPr;
    TP  = short_BTarget1;
    SL =  short_stop;
    win = if Bar_index < 1 then 0 else win[1];
    los = if Bar_index < 1 then 0 else los[1];
    profit = if Bar_index < 1 then 0 else profit[1];
    losses = if Bar_index < 1 then 0 else losses[1];
    TradeisON = yes;
} else

if LongTrade and TradeisON[1]  {
    entry = entry[1];
    TP = TP[1];
    SL = SL[1];
    profit = if high >= TP then profit[1] + AbsValue(close - entry) * share else profit[1];
    losses = if low <= SL then losses[1] + AbsValue(entry - close) * share else losses[1];
    win    = if high >= TP then win[1] + 1 else win[1];
    los    = if low <= SL then los[1] + 1 else los[1];
    TradeisON = if high >= TP then no else
               # if (if SLLong then close else low) <= SL then no else TradeisON[1];
                 if  low <= SL then yes else TradeisON[1];
} else
if ShortTrade and TradeisON[1]  {
    entry = entry[1];
    TP = TP[1];
    SL = SL[1];
    win = if low <= TP then win[1] + 1 else win[1];
    los = if high >= SL then los[1] + 1 else los[1];
    profit = if low <= TP then profit[1] + AbsValue(entry - close) * share else profit[1];
    losses = if high >= SL then losses[1] + AbsValue(close - entry) * share else losses[1];

    TradeisON = if low <= TP then no else
                if   high >= SL then yes else TradeisON[1];
            # if (if slshort then close else high) >= SL then no else TradeisON[1];
} else {
    entry = na;
    win = if Bar_index < 1 then 0 else win[1];
    los = if Bar_index < 1 then 0 else los[1];
    profit = if Bar_index < 1 then 0 else profit[1];
    losses = if Bar_index < 1 then 0 else losses[1];
    TradeisON = TradeisON[1];
    TP = if TradeisON then TP[1] else na;
    SL = if TradeisON then SL[1] else na;
}


#-- Backtest
plot TradeEnd = if !TradeisON and TradeisON[1] then
                if los > los[1] then SL[1] else TP[1] else na;
TradeEnd.AssignValueColor(if win > win[1] then Color.GREEN else Color.RED);
TradeEnd.SetPaintingStrategy(PaintingStrategy.SQUARES);

#-- Label
def totTrade = win + los;
def winRate = Round(win / totTrade * 100, 0);
def PandL   = Round(profit - losses, 2);

input showinfolabel = yes;
AddLabel(showInfoLabel, "Tot Trade: " + totTrade, Color.WHITE);
AddLabel(showInfoLabel, "P/L: $" + PandL,
                        if PandL > 0 then Color.LIGHT_GREEN else
                        if PandL < 0 then Color.PINK else Color.GRAY);
AddLabel(showInfoLabel, "Losses: $" + round(losses,2),  color.red);
AddLabel(showInfoLabel, "WinRate: " + winRate + "%",
                        if winRate > 50 then Color.GREEN else
                        if winRate < 50 then Color.RED else Color.GRAY);
AddLabel(showInfoLabel, "Win: " + win, Color.GREEN);
AddLabel(showInfoLabel, "Loss: " + los, Color.RED);

 


#-- END of CODE
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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