Ichimoku EMA Bands Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
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:

Sree

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

Thank you!
 
Last edited:

john3

Active member
2019 Donor
I haven't seen this before. It seems interesting. Would somebody please convert this to TOS? The indicator is called Ichimoku Hybrid Fibs.

Code:
// @version=3
// @author mata
//
// Extends some of the ideas used in Ichimoku to use Fibonacci principles. This is particularly useful when the price
// is not between Tenkan/Kijun to provide resistance/support points. Similarly, it can provide crossing signals, clues
// about the trend direction, and oversold/overbought indications.
//
// Please note the "Retracement" option in the settings menu.

// Metadata
study(title="Ichimoku Fibonacci Hybrid", shorttitle="IchiFib", overlay=true)

// User inputs
tenkan_periods = input(21, title="Conversion Line Periods"),
kijun_periods = input(60, title="Base Line Periods")
retracements = input(defval=true, type=bool, title="Retracements")

// Functions for computing Fib Retracements
lower(len) => retracements ? lowest(len) + (highest(len) - lowest(len)) * 0.382 : (highest(len) + lowest(len)) * 0.382
higher(len) => retracements ? highest(len) - (highest(len) - lowest(len)) * 0.382 : (highest(len) + lowest(len)) * 0.618
    
mid(len) => (lowest(len) + highest(len)) * 0.5

// Compute the lines
tenkan_lower = lower(tenkan_periods)
kijun_lower = lower(kijun_periods)
tenkan_higher = higher(tenkan_periods)
kijun_higher = higher(kijun_periods)
tenkan_mid = mid(tenkan_periods)
kijun_mid = mid(kijun_periods)


// Plot the lines
upper_band1 = plot(tenkan_higher, color=#AA2200, title="Tenkan Line (High)")
upper_band2 = plot(kijun_higher, color=#FF5500, title="Kijun Line (High)")
lower_band1 = plot(tenkan_lower, color=#0055FF, title="Tenkan Line (Low)")
lower_band2 = plot(kijun_lower, color=#0022AA, title="Kijun Line (Low)")
plot(tenkan_mid, color=#CCAA99, title="Tenkan Line (Mid)")
plot(kijun_mid, color=#AA9977, title="Kijun Line (Mid)")

lowest_band = min(kijun_lower, tenkan_lower)
highest_band = max(tenkan_higher, kijun_higher)
x = plot(lowest_band, editable=false, transp=100)
y = plot(highest_band, editable=false, transp=100)
fill(x, y, transp=94, title="Bands")
 

imnobody

Member
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:

horserider

Well-known member
VIP
Def Bullish = kijun1 > "span A" and "span B";
Def Bearish = kijun1 < "span A" and "span B";

AddLabel (yes, if Bullish then "Bullish" else "Bearish");
 

imnobody

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

markos

Well-known member
VIP
# 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:

shanej

New member
Hello All and thank you for this forum.

I have been learning about MTF support/resistance while using ichimoku.

So I like to look at the 4hr chart first and then mark where the T, K, and SpanB lines are. Then I filter through the timeframes starting at 5m and going up to a day. I looking for any line to intersect on different timeframes. For example, if on the 4hr the Tenkan is at 10$ and i filter to the 5m and see that the SpanB line is at the 10$ mark and on the 2 hr the Kijun is on the 10$, The potential of the plots on the original Time Frame match multiple timeframes possible.

The ultimate goal is to find strong support/resistance across multiple time frames to see where the day, swing, and long traders agree on.

My question is it possible to code a scan for multiple time frames to see where the T, K. and SpanB intersect and then also display on the chart what time frame and which line is intersecting with the original timeframe?


hope this makes sense.

Shane J
 
Last edited by a moderator:

shanc

New member
Hi, could someone help me to add alert for conditions below? Thank you very much.

If blue line is above the grey cloud, bullish trend.
If red line is below the grey cloud, bearish trend.
 

wtf_dude

Active member
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 ass 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:

tenacity11

Active member
2019 Donor
This is interesting and I'm going to watch it for awhile. I've been following the Ichimoku cloud.
 

wtf_dude

Active member
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.
 

tenacity11

Active member
2019 Donor
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
 

wtf_dude

Active member
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.
 

tenacity11

Active member
2019 Donor
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
 

wtf_dude

Active member
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.
 

rad14733

Moderator
Staff member
VIP
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...
 

Similar threads

Top