False Breakout (Expo) For ThinkOrSwim

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

hello gang. i hope someone here can help me and help the group! thanks in advance
find out below
KyqzIZX.png

I added some more options can be enable/disable.
Author Message:
False Breakout (Expo) is an indicator that detects false breakouts in real-time. A false breakout occurs when the price moves through a certain level but doesn't continue to accelerate in that direction. This is because the price does not have enough momentum and the buying interest at this level is not high enough to keep pushing the price in that direction. Instead, the market reverses! All breakout traders are now forced to close their positions at a loss. However, contrarian traders that have identified this false breakout do get a perfect entry for a great reversal trade!
CODE:
CSS:
#// © Zeiierman
#https://www.tradingview.com/v/vz0bVIJo/
#indicator("False Breakout (Expo)",overlay=true,max_bars_back = 2000)
# Converted and mod By Sam4Cok@Samer800 - 11/2022

#// ~~ inputs {
input Source     = close;
input HighLowBand = no;
input highlightArea = no;
input FalseBreakoutLines  = yes;
input autoExtendLines     = yes;
input MaxLinesLength = 20;    #Hint MaxLinesLength: Adjust max lengtth of lines if "Auto Extend Lines" disabled.
input signalStyle    = {Arrows,Default Bubbles, None};
input smoothingType  = {default "None", "WMA", "HMA"}; # Smoothing"
input lookbackPeriod = 20; # "False Breakout Period"
input minPeriod  = 5;  # "New Breakout within minimum X bars"
input maxPeriod  = 5;  # "Signal valid for X bars"
input smoothingLength = 10; # "Smoothing Length"
input aggressiveMode  = no; # "This filter enables a more aggressive false breakout detection."

def na = Double.NaN;
def n  = BarNumber();
def h  = high;
def l  = low;
def c  = Source;
def style = if signalStyle==signalStyle.Arrows then 1 else
            if signalStyle==signalStyle.Bubbles then -1 else 0;
#// ~~ var {
def val;
def falsebreakoutup;
def falsebreakoutdown;
def count;
def indx0;
def indx1;
def bar;
#// ~~ smoothing {
script smoothing {
    input maType = "WMA";
    input src = close;
    input len = 14;
    def ma = if maType == "WMA" then WMA(src, len) else
             if maType == "HMA" then HullMovingAvg(src, len) else src;
    plot return = ma;
}
#// ~~ new high/low {
def hSrc = If(aggressiveMode, l, h);
def lSrc = If(aggressiveMode, h, l);
def hh     = Highest(hSrc, lookbackPeriod);
def ll     = Lowest(lSrc, lookbackPeriod);
def hi     = smoothing(smoothingType, hh, smoothingLength);
def lo     = smoothing(smoothingType, ll, smoothingLength);
def condHi = hi > hi[1] and hi[1] <= hi[2];
def condLo = lo < lo[1] and lo[1] >= lo[2];

#// ~~ count {
if condHi {
    count = If(count[1] > 0, 0, count[1]) - 1;
    val   = l;
    indx0 = n;
    indx1 = indx0[1];
    bar   = n;
} else {
    if condLo {
        count = If(count[1] < 0, 0, count[1]) + 1;
        val   = h;
        indx0 = n;
        indx1 = indx0[1];
    bar   = n;
    } else {
        count = If(falsebreakoutup[1] or falsebreakoutdown[1], 0, count[1]);
        val   = val[1];
        indx0 = indx0[1];
        indx1 = indx1[1];
    bar   = n;
    }
}
#// ~~ cond {
def minbars   = (indx1 + minperiod) < indx0;
def maxvalid  = (n - maxperiod) <= indx0;
def breakD    = if c < val then breakD[1] + 1 else 0;
def breakU    = if c > val then breakU[1] + 1 else 0;
def breakdown = breakD == 1;
def breakup   = breakU == 1;
falsebreakoutup   = count < -1 and breakdown and maxvalid and minbars;
falsebreakoutdown = count > 1 and breakup and maxvalid and minbars;

#//~~~}
def ComUp = CompoundValue(1, if falsebreakoutup then val else ComUp[1], val);
def ComDn = CompoundValue(1, if falsebreakoutdown then val else ComDn[1], val);

def valUp = if ComUp==ComUp[1] then valUp[1] + 1 else 0;
def valDn = if ComDn==ComDn[1] then valDn[1] + 1 else 0;

plot UpLine = if isNaN(c) or if(autoExtendLines,no,valUp>MaxLinesLength) then na else ComUp[-2];
plot DnLine = if isNaN(c) or if(autoExtendLines,no,valDn>MaxLinesLength) then na else ComDn[-2];
UpLine.SetPaintingStrategy(PaintingStrategy.POINTS);
DnLine.SetPaintingStrategy(PaintingStrategy.POINTS);
UpLine.SetDefaultColor(Color.DARK_RED);
DnLine.SetDefaultColor(Color.DARK_GREEN);
UpLine.SetHiding(!FalseBreakoutLines);
DnLine.SetHiding(!FalseBreakoutLines);
#// ~~ plot {
plot hiBand = hi;
hiBand.SetDefaultColor(Color.DARK_RED);
hiBand.SetHiding(!HighLowBand);
plot loBand= lo;
loBand.SetDefaultColor(Color.DARK_GREEN);
loBand.SetHiding(!HighLowBand);

plot valLine = val;
valLine.SetHiding(yes);

#---- Signals
plot ArrowDn = if style>0 and falsebreakoutup then h else na;
plot ArrowUp = if style>0 and falsebreakoutdown then l else na;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
ArrowDn.SetDefaultColor(Color.MAGENTA);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowDn.SetLineWeight(2);
ArrowUp.SetLineWeight(2);

#-- Bubbles
AddChartBubble(style<0 and falsebreakoutup, h, "FalseBreakUp", Color.MAGENTA, yes);
AddChartBubble(style<0 and falsebreakoutdown, l, "FalseBreakDn", Color.CYAN, no);
#-- Cloud
AddCloud(if !highlightArea then na else valLine, UpLine, CreateColor(1, 25, 16), CreateColor(38, 0, 0));
AddCloud(if !highlightArea then na else valLine, DnLine, CreateColor(1, 25, 16), CreateColor(38, 0, 0));

#---- END
 
find out below
KyqzIZX.png

I added some more options can be enable/disable.
Author Message:
False Breakout (Expo) is an indicator that detects false breakouts in real-time. A false breakout occurs when the price moves through a certain level but doesn't continue to accelerate in that direction. This is because the price does not have enough momentum and the buying interest at this level is not high enough to keep pushing the price in that direction. Instead, the market reverses! All breakout traders are now forced to close their positions at a loss. However, contrarian traders that have identified this false breakout do get a perfect entry for a great reversal trade!
CODE:
CSS:
#// © Zeiierman
#https://www.tradingview.com/v/vz0bVIJo/
#indicator("False Breakout (Expo)",overlay=true,max_bars_back = 2000)
# Converted and mod By Sam4Cok@Samer800 - 11/2022

#// ~~ inputs {
input Source     = close;
input HighLowBand = no;
input highlightArea = no;
input FalseBreakoutLines  = yes;
input autoExtendLines     = yes;
input MaxLinesLength = 20;    #Hint MaxLinesLength: Adjust max lengtth of lines if "Auto Extend Lines" disabled.
input signalStyle    = {Arrows,Default Bubbles, None};
input smoothingType  = {default "None", "WMA", "HMA"}; # Smoothing"
input lookbackPeriod = 20; # "False Breakout Period"
input minPeriod  = 5;  # "New Breakout within minimum X bars"
input maxPeriod  = 5;  # "Signal valid for X bars"
input smoothingLength = 10; # "Smoothing Length"
input aggressiveMode  = no; # "This filter enables a more aggressive false breakout detection."

def na = Double.NaN;
def n  = BarNumber();
def h  = high;
def l  = low;
def c  = Source;
def style = if signalStyle==signalStyle.Arrows then 1 else
            if signalStyle==signalStyle.Bubbles then -1 else 0;
#// ~~ var {
def val;
def falsebreakoutup;
def falsebreakoutdown;
def count;
def indx0;
def indx1;
def bar;
#// ~~ smoothing {
script smoothing {
    input maType = "WMA";
    input src = close;
    input len = 14;
    def ma = if maType == "WMA" then WMA(src, len) else
             if maType == "HMA" then HullMovingAvg(src, len) else src;
    plot return = ma;
}
#// ~~ new high/low {
def hSrc = If(aggressiveMode, l, h);
def lSrc = If(aggressiveMode, h, l);
def hh     = Highest(hSrc, lookbackPeriod);
def ll     = Lowest(lSrc, lookbackPeriod);
def hi     = smoothing(smoothingType, hh, smoothingLength);
def lo     = smoothing(smoothingType, ll, smoothingLength);
def condHi = hi > hi[1] and hi[1] <= hi[2];
def condLo = lo < lo[1] and lo[1] >= lo[2];

#// ~~ count {
if condHi {
    count = If(count[1] > 0, 0, count[1]) - 1;
    val   = l;
    indx0 = n;
    indx1 = indx0[1];
    bar   = n;
} else {
    if condLo {
        count = If(count[1] < 0, 0, count[1]) + 1;
        val   = h;
        indx0 = n;
        indx1 = indx0[1];
    bar   = n;
    } else {
        count = If(falsebreakoutup[1] or falsebreakoutdown[1], 0, count[1]);
        val   = val[1];
        indx0 = indx0[1];
        indx1 = indx1[1];
    bar   = n;
    }
}
#// ~~ cond {
def minbars   = (indx1 + minperiod) < indx0;
def maxvalid  = (n - maxperiod) <= indx0;
def breakD    = if c < val then breakD[1] + 1 else 0;
def breakU    = if c > val then breakU[1] + 1 else 0;
def breakdown = breakD == 1;
def breakup   = breakU == 1;
falsebreakoutup   = count < -1 and breakdown and maxvalid and minbars;
falsebreakoutdown = count > 1 and breakup and maxvalid and minbars;

#//~~~}
def ComUp = CompoundValue(1, if falsebreakoutup then val else ComUp[1], val);
def ComDn = CompoundValue(1, if falsebreakoutdown then val else ComDn[1], val);

def valUp = if ComUp==ComUp[1] then valUp[1] + 1 else 0;
def valDn = if ComDn==ComDn[1] then valDn[1] + 1 else 0;

plot UpLine = if isNaN(c) or if(autoExtendLines,no,valUp>MaxLinesLength) then na else ComUp[-2];
plot DnLine = if isNaN(c) or if(autoExtendLines,no,valDn>MaxLinesLength) then na else ComDn[-2];
UpLine.SetPaintingStrategy(PaintingStrategy.POINTS);
DnLine.SetPaintingStrategy(PaintingStrategy.POINTS);
UpLine.SetDefaultColor(Color.DARK_RED);
DnLine.SetDefaultColor(Color.DARK_GREEN);
UpLine.SetHiding(!FalseBreakoutLines);
DnLine.SetHiding(!FalseBreakoutLines);
#// ~~ plot {
plot hiBand = hi;
hiBand.SetDefaultColor(Color.DARK_RED);
hiBand.SetHiding(!HighLowBand);
plot loBand= lo;
loBand.SetDefaultColor(Color.DARK_GREEN);
loBand.SetHiding(!HighLowBand);

plot valLine = val;
valLine.SetHiding(yes);

#---- Signals
plot ArrowDn = if style>0 and falsebreakoutup then h else na;
plot ArrowUp = if style>0 and falsebreakoutdown then l else na;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_Up);
ArrowDn.SetDefaultColor(Color.MAGENTA);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowDn.SetLineWeight(2);
ArrowUp.SetLineWeight(2);

#-- Bubbles
AddChartBubble(style<0 and falsebreakoutup, h, "FalseBreakUp", Color.MAGENTA, yes);
AddChartBubble(style<0 and falsebreakoutdown, l, "FalseBreakDn", Color.CYAN, no);
#-- Cloud
AddCloud(if !highlightArea then na else valLine, UpLine, CreateColor(1, 25, 16), CreateColor(38, 0, 0));
AddCloud(if !highlightArea then na else valLine, DnLine, CreateColor(1, 25, 16), CreateColor(38, 0, 0));

#---- END
@samer800 you are awesome. thank you very much
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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