Ichimoku EMA Bands Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
You may find the default Ichimoku cloud indicator confusing. Well, here is the simplified version of that with EMA bands included for ThinkorSwim.

This was converted from the original TradingView version. According to the developer, here are the conditions to buy and sell.

Ichimoku Signals:
  • Red (bearish) or Blue (bullish) line represents trend.
  • If blue line is above the grey cloud, bullish trend is stronger.
  • If red line is below the grey cloud, bearish trend is stronger.
  • Buy when candle close above the line or short when candle close below it.
  • Take profit when price touches the band and exceeds.

You can use this indicator on any timeframes you like but I recommend the hourly and daily chart. It's good for knowing the long term trend.

61CsWhf.png


thinkScript Code

Rich (BB code):
# Converted by WalkingBallista with help from Benten
# Source: https://www.tradingview.com/script/2TicXK2B-Ichimoku-EMA-Bands/
# https://usethinkscript.com/d/106-ichimoku-ema-bands-indicator-for-thinkorswim
# Ichimoku
#
input tenkan_period = 5;
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;
def Chikou = close[-kijun_period];

DefineGlobalColor("A", Color.Dark_Gray);
DefineGlobalColor("B", Color.Dark_Gray);
DefineGlobalColor("Bull", Color.Blue);
DefineGlobalColor("Bear", Color.Red);
Tenkan.SetDefaultColor(Color.Orange);
Kijun.AssignValueColor(if close >= Kijun then GlobalColor("Bull") else GlobalColor("Bear"));
"Span A".SetDefaultColor(GlobalColor("A"));
"Span B".SetDefaultColor(GlobalColor("B"));

AddCloud("Span A", "Span B", GlobalColor("A"), GlobalColor("B"));

#
# EMAs
#

declare weak_volume_dependency;

input displace = 0;
input ema_length = 26;

input atr_factor = 2.272;
input atr_length = 200;
input price = close;
input averageType = AverageType.EXPONENTIAL;
input trueRangeAverageType = AverageType.WILDERS;

def shift = atr_factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), atr_length);

def average = MovingAverage(averageType, price, ema_length);

plot Avg = average[-displace];
Avg.SetDefaultColor(Color.Black);

plot Upper_Band = average[-displace] + shift[-displace];
Upper_Band.SetDefaultColor(Color.Red);

plot Lower_Band = average[-displace] - shift[-displace];
Lower_Band.SetDefaultColor(Color.Green);

Shareable Link

https://tos.mx/MnLRFo

Credits:
 
Last edited:

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

Hi New joiner here, please help to plot Chikou span as well with provisions to set color.

Thank you!
 
Last edited:
@Sree See above link. Thanks @markos

 
Last edited:
Code:
input BuyLabelText4 = " Chikou (+) ";

input SellLebelText4 = " Chikou (-) ";


input tenkan_period = 9;
input kijun_period = 26;

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

plot tenkan1 = tenkan;
plot kijun1 = kijun;
plot "span A1" = "span A";
plot "span b1" = "span b";
plot chikou1 = chikou;


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

AddLabel (yes, if chikou > "span A" and "span B" then BuyLabelText4 + " " else SellLebelText4 + " ", if  chikou < "span B" and "span a" then Color.RED

                           else  

                            Color.GREEN);


Can't get the label to work not sure what i'm doing wrong.
 
Last edited by a moderator:
Def Bullish = kijun1 > "span A" and "span B";
Def Bearish = kijun1 < "span A" and "span B";

AddLabel (yes, if Bullish then "Bullish" else "Bearish");
 
figured it out finally. about banged my head into a desk trying to.

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(Color.ORANGE);
Kijun.SetDefaultColor(Color.BLUE);
"Span A".SetDefaultColor(Color.GREEN);
"Span B".SetDefaultColor(Color.RED);
Chikou.SetDefaultColor(Color.LIGHT_GRAY);

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

def Long = close > "Span B" AND "Span A" > "Span B";
def Short = close < "Span A" AND "Span A" < "Span B";

def crossUpper = (close crosses above Kijun) OR (Tenkan > Kijun);
def crossLower = (close crosses below Kijun) OR (Tenkan < Kijun);

def Bull_trading_signal = Long is true and crossUpper is true;
def Bear_trading_signal = Short is true and crossLower is true;


AddLabel( if long is true then yes else no, "Above Cloud", CreateColor(51, 204, 0));
AddLabel(if short is true then yes else no, "Below Cloud", color.RED);
AddLabel( if crossUpper is true then yes else no, "TK x", CreateColor(51, 204, 0));
AddLabel(if crossLower is true then yes else no, "KT x", color.RED);
 
# From TSL in March 2018
#19:14 Mobius: Do you know what Ichimoku actually is, in logic/math terms? It's a Detrended Range Study.
#19:17 Mobius: Here is Ichimoku with meaningful names. Names that identify what is happening in the study
#19:19 Mobius: Ichimoku is nothing more than ATR with extended ranges that are detrended.
#19:20 Mobius: Makes no difference what the lenghts used in the study are. All Same.
#19:21 Mobius: Not trying to burst anyone's bubble. Just trying to help folks understand clearly what they're using to make trading decisions For example, If your using Ichimoku and you want to confirm signals, you'd naturally not want to use multicollinear studies. So studies like ATR and Keltner Channels and the like would be studies to avoid.
Code:
# Ichimoku Demystifyed
# Nothing but the names have been changed to ones that have meaning
# Mobius 3-2018

input Short_period = 9;
input Long_period = 26;

def h = high;
def l = low;
def c = close;
plot Short_Range = (Highest(h, Short_period) + Lowest(l, Short_period)) / 2;
plot Long_Range = (Highest(h, Long_period) + Lowest(l, Long_period)) / 2;
plot "Avg SR_LR" = (Short_Range[Long_period] + Long_Range[Long_period]) / 2;
plot "Avg SuperRange" = (Highest(h[Long_period], 2 * Long_period) + Lowest(l[Long_period], 2 * Long_period)) / 2;
plot DetrendedClose = c[-Long_period];

Short_Range.SetDefaultColor(GetColor(1));
Long_Range.SetDefaultColor(GetColor(2));
"Avg SR_LR".SetDefaultColor(GetColor(3));
"Avg SuperRange".SetDefaultColor(GetColor(4));
DetrendedClose.SetDefaultColor(GetColor(5));

DefineGlobalColor("Bullish", Color.YELLOW);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Avg SR_LR", "Avg SuperRange", globalColor("Bullish"), globalColor("Bearish"));

#17:03 AlphaInvestor: I posted the Ichimoku Demystified above ... with some of the original dialog from Mobius
 
Last edited by a moderator:
Hey guys

Another quarantine idea for ya. Below you'll find my Ichimoku system variation and tutorial.

Hope you can find some use for it.

j5hKLdD.png


Code:
# IchiPhoKyu System v1.0 by WTF_Dude
#
#
# WTF_Dude's Ichimoku variation and tutorial
#
# The tenkan is the blue line. Don't NOT look at it as short term support and resistance as usual. Instead, think of the line as your price magnet. The price will NEVER stray too far from the magnet. Find the furthest point away it's strayed in the past bars of your current chart and think of that as the price's limit.
# The orange line is the Kijun. You'll notice it doesn't look like it normally does and that will explained in a moment. Many people dont even use this one in the normal system anymore, but if you want a short term support and resistance line then this is the one you want to use instead of blue. The alternative way to use the orange line is for a short term crossover. If the blue line (tenkan) crosses below the orange (kijun), it's short term bearish and vice versa.
# The 5th number in the settings is for the previously mentioned Kijun variation(orange line) The number is a length for an EMA. It is often much easier to see the price movement clearly with the the EMA rather than with the typical Kijun (it will also slightly shift the crossover) An EMA of 30 works as a near perfect substitute of the regular 26 Kijun. You can always manually change back to the typical Kijun in settings by clicking "show plot".
# Below both you have the red and green "Kemo" cloud. This is your "overall" trend indicator. If the price is above this green or red cloud, the overall trend is bullish. If it's below, bearish. If WITHIN the cloud, trend may be changing gears or just consolidating. You'll notice that the cloud sticks out ahead of the price in time. That acts as a forecaster. If the cloud ahead is green, the trend will likely stay bullish. Viceversa for then cloud turning red.
# The dark green line (border of the cloud) acts acts as very weak support or resistance
# The dark red line is STRONG support or resistance, but can also act as another magnet It is not uncommon for the price to stick it's *** out below the red line for 2 or 3 bars only to then shoot back up into the cloud. Always look for 2 or 3 bars that are completely below the redline for the trend change confirmation. If the price GAPS UP OR DOWN completely out of the cloud. Then that's an immediate signal or buy or sell.
# Another point: the thicker the cloud that the price breaks through, the better the trend change confirmation. If the trend was bearish and price finally breaks up above a thick red cloud, that's a really strong move. If its a wimpy little sliver of a cloud that the price breaks through, don't place huge bets on a trend continuation just yet.
# Normally, the numbers that calculate the blue and orange lines also determine where the cloud is in time and the thickness. Here you can actually displace the cloud forward and backward as well as shift the thickness and placement of the red base line on it's own. The standard Ichimoku system shifts the kemo cloud forward 26 bars. The default shift for this is only 16 (Ichimoku default of 26 shifted 10 bars backwards). You will likely find that this setting causes the price to follow the cloud much more clearly. Leaving the Base_Line setting at 52 approximates the original 52 found in the default Ichimoku set.
# There is no lagging span (chikou) in the system by default (HINT: you unhide the lagging span if you're an old school Ichi user and really want to add the stupid thing. However, I find that it is largely a relic and doesn't tend to work well anymore as a signal)
# Feel free to adjust the settings as needed. Enjoy



input Tenkan = 9;
input Kijun = 26;
input Cloud_Shift = 16;
input Base_Line =52;
input KijunAvg = 30;

def h = high;
def l = low;
def c = close;

plot TenkanShort = (Highest(h, Tenkan) + Lowest(l,Tenkan)) / 2;
plot KijunLong = (Highest(h, Kijun) + Lowest(l, Kijun)) / 2;
kijunlong.hide();
plot "Span A" = (TenkanShort[Cloud_Shift] + KijunLong[Cloud_Shift]) / 2;
plot "Span Base" = (Highest(h[Cloud_Shift],Base_Line) + Lowest(l[Cloud_Shift], Base_Line)) / 2;
plot KijunEMA = MovAvgExponential(close, KijunAvg);
plot LaggingClose = c[- Kijun];
laggingclose.hide();

TenkanShort.SetDefaultColor(color.cyan);
KijunLong.SetDefaultColor(color.dark_orange);
"Span A".SetDefaultColor(color.dark_green);
"Span Base".SetDefaultColor(color.dark_red);
LaggingClose.SetDefaultColor(Color.Dark_Green);
KijunEMA.setdefaultcolor(color.dark_orange);


DefineGlobalColor("Bullish", Color.dark_green);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Span A", "Span Base", globalColor("Bullish"), globalColor("Bearish"));

Shareable link: https://tos.mx/N9DW02e
 
Last edited by a moderator:
This is interesting and I'm going to watch it for awhile. I've been following the Ichimoku cloud.
 
This is interesting and I'm going to watch it for awhile. I've been following the Ichimoku cloud.
Let me know your results and feel free to play with the settings. It's a work in progress, but the following of price seems to me to be much more accurate.
 
Let me know your results and feel free to play with the settings. It's a work in progress, but the following of price seems to me to be much more accurate.
I will. Curious if you've worked with this on a very small timeframe like a 3m
 
I will. Curious if you've worked with this on a very small timeframe like a 3m
I have not, I'm only a swing trader. To my knowledge, Ichi studies only work well on longer time frame. The original system was based on days going to weeks. Intraday movement is completely different.
 
I have not, I'm only a swing trader. To my knowledge, Ichi studies only work well on longer time frame. The original system was based on days going to weeks. Intraday movement is completely different.
Well we're about to find out how this goes on smaller timeframes. With the market the way it is I won't hold overnight. Keep ya posted..I'm going to try to play around with the Kijun EMA
 
Well we're about to find out how this goes on smaller timeframes. With the market the way it is I won't hold overnight. Keep ya posted..I'm going to try to play around with the Kijun EMA
Just remember the kijun ema is just a 30period EMA so it's main usage is for the first line of support or for the tenkan/kijun crossover.
 
I will. Curious if you've worked with this on a very small timeframe like a 3m
I tested the original Ichimoku study a few months ago for day trading but don't recall if I made any major changes... Well, actually, I used it to monitor the underlying stocks to provide entry and exit signals for option trades... As I recall, I had mixed results but they may not have been due to the indicator itself... It would be interesting to see how this version from wtf_dude compares to the original...
 
and also a scanner that shows pulling back to the 9ema AFTER a spike down. I've been searching everywhere on Thinkscript and can't find it
 
Trying to understand Ichimoku indicator
Is it as simple as: When the price is below the cloud, the trend is down. When the price is above the cloud, the trend is up??
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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