Ichimoku EMA Bands Indicator for ThinkorSwim

BenTen

Administrative
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.



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:

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

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.
 

Similar threads

Top