TOP Ultimate Breakout Indicator for ThinkorSwim

Chuck,

Your chart looks great. Also, is there any documentation on KIP indicators and strategy on the chart configuration? Thank you in advance for the UseThinkScript team's help in this matter.
 
Last edited:

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

Attachments

  • Screenshot 2024-09-25 222100.jpg
    Screenshot 2024-09-25 222100.jpg
    180.6 KB · Views: 238
I liked this script https://tos.mx/WwRo9Iq, but I have a qstn here. Highlighted 3 horizontal price bars. $6.52 is entry, 6.11 and 5.71 stop loss ones? Appreciate your response.
When initiating a discussion with a member concerning a very old post; it is recommended that you click on the members' name to determine if the member is still active.
@Chuck is not an active member.

I would assume that your presumptions are correct and that how the OP means for his chart to be interpreted.
 
@hoojsn Load the following code, I have cleaned it up for you so that the editor no longer complains of any syntax errors.
Please note that I did not make any changes to the logic

Code:
input BuyorSell = {default Buy, Sell};
input BuyEntry = 3;
input SellEntry = 3;
input BuyExit = 20;
input SellExit = 20;
input ATRLength = 50;
input TargetATRMult = 1;
input DisplayLines = yes;
#input PriceDigits=NumberFormat.TWO_DECIMAL_PLACES;

input PriceDigit=2;

def H = high;
def L = low;

def h1 = Highest(H, SellExit);
def ih2=if H != h1 then H else 0.0;
#def h2 = Highest(ih2, SellExit);
def h2=fold i =1 to SellExit with ip=0.0 do if GetValue(H,i)==h1 or GetValue(H,i)<ip then ip else GetValue(H,i);
#def h3 = Highest(if (H == h1 or H == h2) then 0 else H, SellExit);
def h3=fold i1 =1 to SellExit with ip1=0.0 do if GetValue(H,i1)==h1 or GetValue(H,i1)==h2 or GetValue(H,i1)<ip1 then ip1 else GetValue(H,i1);
def HH = (h2 + h3) / 2.0;

#plot pHH=HH;

def l1 = Lowest(L, BuyExit);
#def l2 = Lowest(if L == l1 then 1000000 else L, BuyExit);
def l2=fold i2 =1 to BuyExit with ip2=10000000.0 do if GetValue(L,i2)==l1 or GetValue(L,i2)>ip2 then ip2 else GetValue(L,i2);
def l3 = Lowest(if L == l1 or L == l2 then 1000000 else L, BuyExit);
def LL = (l2 + l2) / 2.0;

def QB = Highest(H, BuyEntry);
def QS = Lowest(L, SellEntry);

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

def dl = DisplayLines == yes;
def trade;
plot entry;

switch (BuyorSell){
case Buy:
    trade = 1;
#entry.SetDefaultColor(color.GREEN);
case Sell:
    trade = -1;
}
#AddLabel(1,trade);
#def c1 = (BuyorSell == "Buy") and barnumber() > Max(SellExit, BuyExit);
#def c2 = (BuyorSell == "Sell") and Barnumber() > Max(SellExit, BuyExit);

entry.AssignValueColor(if trade == 1 then Color.GREEN else if trade == -1 then Color.RED else Color.GREEN);
#entry.setPaintingStrategy(paintingStrategy.LINE);
plot exit;
exit.SetDefaultColor(Color.CYAN);

def EntryPr;
def co = BarNumber() > Max(SellExit, BuyExit);
def pos;

switch (BuyorSell){
case Buy:
    entry = QB[1];
    exit = LL[1];
    pos = if co and high > QB[1] then 1 else if low < LL[1] then 0 else pos[1];
    EntryPr = if high > QB[1] and pos == 1 and pos[1] < 1 then QB[1] else if pos == 0 then Double.NaN else EntryPr[1];

case Sell:
    entry = QS[1];
    exit = HH[1];
    pos = if co and low < QS[1] then -1 else if high[1] > HH[2] then 0 else pos[1];
    EntryPr = if low < QS[1] and pos == -1 and pos[1] > -1 then QS[1] else if pos == 0 then Double.NaN else EntryPr[1];
}

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

switch (BuyorSell){
case Buy:
    BTarget = if pos == 1 and pos[1] < 1 then (EntryPr + (TargetATRMult * 2 * mATR)) else if pos == 1 then BTarget[1] else Double.NaN;
    BTarget2 = if pos == 1 and pos[1] < 1 then (EntryPr + 2 * (TargetATRMult * 2 * mATR)) else if pos == 1 then BTarget2[1] else Double.NaN;
    EntryLine = if LL < EntryPr then EntryPr else Double.NaN;
    TradeRisk = (EntryPr - LL) / mATR;

case Sell:
    BTarget = if pos == -1 and pos[1] > -1 then (EntryPr - (TargetATRMult * 2 * mATR)) else if pos == -1 then BTarget[1] else Double.NaN;
    BTarget2 = if pos == -1 and pos[1] > -1 then (EntryPr - 2 * (TargetATRMult * 2 * mATR)) else if pos == -1 then BTarget2[1] else Double.NaN;
    EntryLine = if HH > EntryPr then EntryPr else Double.NaN;
    TradeRisk = (HH - EntryPr ) / mATR;
}

plot pBTarget = if dl and co then BTarget else Double.NaN;
pBTarget.SetDefaultColor(Color.YELLOW);

plot pBTarget2 = if dl and co then BTarget2 else Double.NaN;
pBTarget2.SetDefaultColor(Color.MAGENTA);

plot pEntryLine = if dl and co then EntryLine else Double.NaN;
pEntryLine.SetDefaultColor(Color.WHITE);

#plot pbt=if dl and co and (pos == 1 or pos == -1) and pos[1] == 0 then BTarget else double.NaN;
#pbt.setPaintingStrategy(paintingStrategy.VALUES_BELOW);

def valco=dl and co and (pos == 1 or pos == -1) and pos[1] == 0;
def rBTarget=round(BTarget,PriceDigit);
def rBTarget2=round(BTarget2,PriceDigit);
def rEntryPr=round(EntryPr,PriceDigit);

AddChartBubble(valco, BTarget,rBTarget, Color.YELLOW);
AddChartBubble(valco, BTarget2, rBTarget2 ,Color.MAGENTA);
AddChartBubble(valco, EntryPr,rEntryPr, Color.WHITE);

def exv=if trade == 1 then LL else HH;
def rexv = round(exv,PriceDigit);
def rTradeRisk = round(TradeRisk,PriceDigit);

AddChartBubble(valco,exv,rexv + "(" +rTradeRisk + "ATR)", Color.CYAN);

#AddChartB=ubble(1,H,pos);

#END
Hi, Does this work for penny stocks too?
 
Hi, Does this work for penny stocks too?


Currently, there are not many penny stock traders on the forum, who would be able to answer your question in detail.

There is nothing in the code that prevents it from being applied to all instruments regardless of price value.
It should be noted that technical indicators require significant volume* to provide optimal results.

*most textbooks define 'significant volume' a minimum of 1,000,000
 
@hoojsn Here - I have converted the code (based on post #1) so that it is a bullish breakout scan.
Additionally I have also formatted the code so that the logic is easier to follow
Scanning against the S&P 500 I obtained 17 results. Have a look at ticker IBM for example

Code:
# Top Ultimate Breakout Scan
# tomsk
# 12.9.2019

input BuyorSell = {default Buy, Sell};
input BuyEntry = 3;
input SellEntry = 3;
input BuyExit = 20;
input SellExit = 20;
input ATRLength = 50;
input TargetATRMult = 1;
input DisplayLines = yes;
input PriceDigit=2;

def H = high;
def L = low;

def H1  = Highest(H, SellExit);
def ih2 = if H != H1
          then H
          else 0.0;
def H2  = fold i = 1 to SellExit
          with ip = 0.0
          do if GetValue(H, i) == H1 or GetValue(H, i) < ip
             then ip
             else GetValue(H, i);

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

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

def QB = Highest(H, BuyEntry);
def QS = Lowest(L, SellEntry);

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

def dl = DisplayLines == yes;
def trade;

switch (BuyorSell) {

case Buy:
    trade = 1;

case Sell:
    trade = -1;
}

def entry;
def exit;
def EntryPr;
def pos;
def co = BarNumber() > Max(SellExit, BuyExit);

switch (BuyorSell) {

case Buy:
    entry = QB[1];
    exit = LL[1];
    pos = if co and high > QB[1] then 1 else if low < LL[1] then 0 else pos[1];
    EntryPr = if high > QB[1] and pos == 1 and pos[1] < 1
              then QB[1]
              else if pos == 0
                  then Double.NaN
              else EntryPr[1];
case Sell:
    entry = QS[1];
    exit = HH[1];
    pos = if co and low < QS[1] then -1 else if high[1] > HH[2] then 0 else pos[1];
    EntryPr = if low < QS[1] and pos == -1 and pos[1] > -1
              then QS[1]
              else if pos == 0
                  then Double.NaN
              else EntryPr[1];
}

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

switch (BuyorSell) {

case Buy:
    BTarget  = if pos == 1 and pos[1] < 1
                   then (EntryPr + (TargetATRMult * 2 * mATR))
               else if pos == 1
                   then BTarget[1]
               else Double.NaN;
    BTarget2 = if pos == 1 and pos[1] < 1
                   then (EntryPr + 2 * (TargetATRMult * 2 * mATR))
               else if pos == 1
                   then BTarget2[1]
               else Double.NaN;
    EntryLine = if LL < EntryPr then EntryPr else Double.NaN;
    TradeRisk = (EntryPr - LL) / mATR;

case Sell:
    BTarget  = if pos == -1 and pos[1] > -1
                   then (EntryPr - (TargetATRMult * 2 * mATR))
               else if pos == -1
                   then BTarget[1]
               else Double.NaN;
    BTarget2 = if pos == -1 and pos[1] > -1
                   then (EntryPr - 2 * (TargetATRMult * 2 * mATR))
               else if pos == -1
                   then BTarget2[1]
               else Double.NaN;
    EntryLine = if HH > EntryPr then EntryPr else Double.NaN;
    TradeRisk = (HH - EntryPr ) / mATR;
}

plot scan = close crosses above entryline;

# End Top Ultimate Breakout Scan
Hi, this indcator won't display on the 5 minute chart? any particular setting i need to change?
 
There sure are lots of variations to user preferences regarding this study. For those that wish to turn the bubbles off, here is version 1,5 of the code - I've added a ShowBubbles input selector, to enable users to toggle the display of bubbles from the user interface. By default the study will display bubbles. For those not conversant with code structure, there is no need to mess with code.

Code:
# 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

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

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 ATRLength = 50;
input TargetATRMult = 1;
input DisplayLines = yes;
input PriceDigit = 2;

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

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

plot entry;
plot exit;

def EntryPr;
def pos;
def co = BarNumber() > Max(SellExit, BuyExit);

switch (BuyorSell) {

case Buy:
    entry = QB[1];
    exit = LL[1];
    pos = if co and high > QB[1] then 1 else if low < LL[1] then 0 else pos[1];
    EntryPr = if high > QB[1] and pos == 1 and pos[1] < 1
              then QB[1]
              else if pos == 0
                  then Double.NaN
              else EntryPr[1];
case Sell:
    entry = QS[1];
    exit = HH[1];
    pos = if co and low < QS[1] then -1 else if high[1] > HH[2] then 0 else pos[1];
    EntryPr = if low < QS[1] and pos == -1 and pos[1] > -1
              then QS[1]
              else if pos == 0
                  then Double.NaN
              else EntryPr[1];
}
entry.AssignValueColor(if BuyorSell == BuyorSell.Buy then Color.GREEN
                       else if BuyorSell == BuyorSell.Sell then Color.RED
                       else Color.CURRENT);
entry.SetHiding(!ShowEntryExitBands);
exit.SetDefaultColor(Color.CYAN);
exit.SetHiding(!ShowEntryExitBands);

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

switch (BuyorSell) {

case Buy:
    BTarget  = if pos == 1 and pos[1] < 1
                   then (EntryPr + (TargetATRMult * 2 * mATR))
               else if pos == 1
                   then BTarget[1]
               else Double.NaN;
    BTarget2 = if pos == 1 and pos[1] < 1
                   then (EntryPr + 2 * (TargetATRMult * 2 * mATR))
               else if pos == 1
                   then BTarget2[1]
               else Double.NaN;
    EntryLine = if LL < EntryPr then EntryPr else Double.NaN;
    TradeRisk = (EntryPr - LL) / mATR;

case Sell:
    BTarget  = if pos == -1 and pos[1] > -1
                   then (EntryPr - (TargetATRMult * 2 * mATR))
               else if pos == -1
                   then BTarget[1]
               else Double.NaN;
    BTarget2 = if pos == -1 and pos[1] > -1
                   then (EntryPr - 2 * (TargetATRMult * 2 * mATR))
               else if pos == -1
                   then BTarget2[1]
               else Double.NaN;
    EntryLine = if HH > EntryPr then EntryPr else Double.NaN;
    TradeRisk = (HH - EntryPr ) / mATR;
}

plot pBTarget = if today and DisplayLines and co then BTarget else Double.NaN;
pBTarget.SetDefaultColor(Color.YELLOW);

plot pBTarget2 = if today and DisplayLines and co then BTarget2 else Double.NaN;
pBTarget2.SetDefaultColor(Color.MAGENTA);

plot pEntryLine = if today and DisplayLines and co then EntryLine else Double.NaN;
pEntryLine.SetDefaultColor(Color.WHITE);

def valco = DisplayLines and co and (pos == 1 or pos == -1) and pos[1] == 0;
def rBTarget = Round(BTarget, PriceDigit);
def rBTarget2 = Round(BTarget2, PriceDigit);
def rEntryPr = Round(EntryPr, PriceDigit);

AddChartBubble(ShowBubbles and today and valco, BTarget, rBTarget, Color.YELLOW);
AddChartBubble(ShowBubbles and today and valco, BTarget2, rBTarget2, Color.MAGENTA);
AddChartBubble(ShowBubbles and today and valco, EntryPr, rEntryPr, Color.WHITE);

def exv=if BuyorSell == BuyorSell.Buy then LL else HH;
def rexv = Round(exv, PriceDigit);
def rTradeRisk = Round(TradeRisk, PriceDigit);

AddChartBubble(ShowBubbles and today and valco, exv, rexv + "(" + rTradeRisk + "ATR)", Color.CYAN);
# End Top Ultimate Breakout Indicator
I am grateful to @tomsk for the conversion of this indicator. I have been testing this indicator for some time and noticed that it works really well in a sideways market. Most of the time hitting the first target and occasionally the second target. However, on a trending market and on market open, the signals are never triggered. I would like to know if anyone can help me analyze why?. I have no knowledge of the rules used here and couldn't figure out why the signals never triggered. The highlighted box displays the indicator values. On 10/01/2024, there was a bearish trend and the signals were never triggered on market open on the third bearish candle (9:32 AM NY time). Also, I was expecting a bearish trigger every time there was a pullback and price crossed and closed at the lower red band. Any help is really appreciated. If anyone has backtested and used this indicator, can you please explain the rules for going long and short?
Screenshot - 10_1_2024 , 11_59_38 AM.png
 
Last edited:
I am grateful to @tomsk for the conversion of this indicator. I have been testing this indicator for some time and noticed that it works really well in a sideways market. Most of the time hitting the first target and occasionally the second target. However, on a trending market and on market open, the signals are never triggered. I would like to know if anyone can help me analyze why?. I have no knowledge of the rules used here and couldn't figure out why the signals never triggered. The highlighted box displays the indicator values. On 10/01/2024, there was a bearish trend and the signals were never triggered on market open on the third bearish candle (9:32 AM NY time). Also, I was expecting a bearish trigger every time there was a pullback and price crossed and closed at the lower red band. Any help is really appreciated. If anyone has backtested and used this indicator, can you please explain the rules for going long and short?
View attachment 23043
What is this specific variation you have?
 

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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