# Ichimoku Breakout For ThinkOrSwim

#### doeoner

##### New member
Hey everyone, I've read through the Ichimoku post's and can't seem to find a break out indicator. I'm looking to set an alert when a candle breaks out from either side of the cloud (green or red) and EMA 8 crosses EMA 50 all within the same candle. Any help is greatly appreciated.

This should get you started at least. Feel free to modify it to your liking.

Code:
``````input tenkan_period = 9;
input kijun_period = 26;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));
"Span A".SetDefaultColor(GetColor(3));
"Span B".SetDefaultColor(GetColor(4));
Chikou.SetDefaultColor(color.dark_red);

DefineGlobalColor("Bullish", Color.YELLOW);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Span A", "Span B", globalColor("Bullish"), globalColor("Bearish"));

input showOutsideCrosses = no;
#input strictMode = no;
input offset = .002;

def SpanUp = if "Span A" > "Span B" then "Span A" else "Span B";
def SpanDn = if "Span A" < "Span B" then "Span A" else "Span B";

def upTrigger1 = if showAlerts and tenkan > kijun and close crosses above SpanUp then 1 else 0;
def dnTrigger1 = if showAlerts and tenkan < kijun and close crosses below SpanDn then 1 else 0;

def upTrigger2 = if showAlerts and showOutsideCrosses and close > SpanUp and tenkan crosses above Kijun then 1 else 0;
def dnTrigger2 = if showAlerts and showOutsideCrosses and close < SpanDn and tenkan crosses below Kijun then 1 else 0;

plot UpSignal = if upTrigger1 or upTrigger2 then low - offset else Double.NaN;
plot DownSignal = if dnTrigger1 or dnTrigger2 then high + offset else Double.NaN;

UpSignal.SetDefaultColor(Color.magenta);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.setLineWeight(3);
UpSignal.hideBubble();
DownSignal.SetDefaultColor(Color.magenta);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.setLineWeight(3);
DownSignal.hideBubble();

#test
#def dataPoint = close[-26];
#plot crossUp = if "Span A" crosses above "Span B" then "Span B" - offset else Double.NaN;
#plot crossDn = if "Span A" crosses below "Span B" then "Span B" + offset else Double.NaN;
#plot crossUp = if upTrigger then dataPoint - offset else Double.NaN;
#plot crossDn = if dnTrigger then dataPoint + offset else Double.NaN;
#crossUp.SetDefaultColor(Color.blue);
#crossUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#crossUp.setLineWeight(3);
#crossUp.hideBubble();
#crossDn.SetDefaultColor(Color.blue);
#crossDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#crossDn.setLineWeight(3);
#crossDn.hideBubble();

def aUp = if upSignal and audioalerts and showAlerts then upSignal else Double.NaN;

87k+ Posts
399 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?