Kijun Trend Indicator for ThinkorSwim

JJSPX

New member
I've found using the Ichimoku can get me cross eyed sometimes, but I've found the Kijun specifically to be very powerful. This in tandem with it's little brother, the Tenkan, can give a good eye on trend. Here's a simple code for "KijunTrend". Hope someone finds it useful!

I do use this along with TPOProfile, volume and a custom candlestick indicator to just visually show the specific candles which I feel give a higher probability regarding future direction than others..... but here's the KijunTrend code.

*I will "hide" the Tenkan and Set as Default when viewing on the chart.

Code:
input price = close;
input tenkan_period = 9;
input kijun_period = 26;
input displace = 0;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
Kijun.DefineColor("Up", Color.GREEN);
Kijun.DefineColor("Down", Color.RED);
Kijun.DefineColor("Even", Color.WHITE);
Kijun.AssignValueColor(if Kijun > Tenkan then Kijun.Color("Down") else (if Kijun == Tenkan then Kijun.Color("Even") else Kijun.Color("Up")));
Kijun.SetLineWeight(3);

Here's an additional (slightly tweaked) bit of code, in case you find it useful. It's the same code, but calls to a higher time frame. You can have a 30min chart up, but have higher time frame (1hr, 4hr, daily, etc) Kijun levels printed on the chart. I've found the Kijun levels to be great, especially when they align with Market Profile.

Code:
input Period = aggregationPeriod.DAY;
def close = close(period = Period);
def high = high(period = Period);
def open = open(period = Period);
def low = low(period = Period);

input price = close;
input tenkan_period = 9;
input kijun_period = 26;
input displace = 0;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
Kijun.DefineColor("Up", Color.GREEN);
Kijun.DefineColor("Down", Color.RED);
Kijun.DefineColor("Even", Color.WHITE);
Kijun.AssignValueColor(if Kijun > Tenkan then Kijun.Color("Down") else (if Kijun == Tenkan then Kijun.Color("Even") else Kijun.Color("Up")));
Kijun.SetLineWeight(3);
 
Last edited by a moderator:

horserider

Well-known member
VIP
You do know your Tenkan and Kijun are the same calculation. How is the Kijun then more powerful?
 

JJSPX

New member
Period length. Same line of thinking as slower v faster moving averages. It was more speaking to (what could be seen as) confusion looking at an entire Ichimoku Cloud vs Kijun specifically. The Kijun line itself can serve as very liable Support/Resistance (vs a more unreliable Tenkan), and also the trend factor (Tenkan > Kijun or Tenkan < Kijun) gives a better picture of market flow in the terms of uptrend/downtrend).
 

mark0482

New member
VIP
Hello friends!

I've found very nice script with Tenkan and Kijun indicator for TOS - but I'd like to add lines for breakout arrows for uptrend and downtrend
Could you help me?

Best regards!

Original code to modify:
Code:
input price = close;
input tenkan_period = 9;
input kijun_period = 26;
input displace = 0;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
Kijun.DefineColor("Up", Color.GREEN);
Kijun.DefineColor("Down", Color.RED);
Kijun.DefineColor("Even", Color.WHITE);
Kijun.AssignValueColor(if Kijun > Tenkan then Kijun.Color("Down") else (if Kijun == Tenkan then Kijun.Color("Even") else Kijun.Color("Up")));
Kijun.SetLineWeight(3);

Id like to add arrows for example like here:

CAD-JPY-2.png
 

rad14733

Well-known member
VIP
Here is some code I wrote last year that would be a good starting point for you... You would just need to make it an upper indicator...

Ruby:
#Ichimoku_Tenkan_Trading_Indicator
#Created by rad14733
#Modified 2020-04-01
declare lower;

input tenkan_period = 9;

#Long Entry Indicator
plot LongEntry = if close from 1 bars ago is greater than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and open from 1 bars ago is less than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and close is greater than or equal to Ichimoku(tenkan_period)."Tenkan" and open is greater than or equal to Ichimoku()."Tenkan" then 1 else 0;
#LongEntry.AssignValueColor(Color.LIGHT_GREEN);
#LongEntry.SetLineWeight(2);

#Long Exit Indicator
plot LongExit =  if close from 1 bars ago is greater than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and open from 1 bars ago is greater than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and close is less than or equal to Ichimoku(tenkan_period)."Tenkan" and open is less than or equal to Ichimoku()."Tenkan" then 1 else 0;
#LongExit.AssignValueColor(Color.DARK_RED);
#LongExit.SetLineWeight(2);

#ShortEntry Indicator
plot ShortEntry = if close from 1 bars ago is less than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and open from 1 bars ago is greater than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and close is less than or equal to Ichimoku(tenkan_period)."Tenkan" and open is less than or equal to Ichimoku()."Tenkan" then 1 else 0;
#ShortEntry.AssignValueColor(Color.LIGHT_RED);
#ShortEntry.SetLineWeight(2);

#Short Exit Indicator
plot ShortExit =  if close from 1 bars ago is less than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and open from 1 bars ago is less than or equal to Ichimoku(tenkan_period)."Tenkan" from 1 bars ago and close is greater than or equal to Ichimoku(tenkan_period)."Tenkan" and open is greater than or equal to Ichimoku()."Tenkan" then 1 else 0;
#ShortExit.AssignValueColor(Color.DARK_GREEN);
#ShortExit.SetLineWeight(2);
 

rad14733

Well-known member
VIP
Ohh thank you rad14733, but unfortunately Im not programmer.

Perhaps you should take the opportunity to help yourself by learning Thinkscript... It wouldn't take much to convert the code I provided to do what you want... We really need to get members interested in coding rather than just asking for others to do their work for them... I'm more than willing to help you along but tire of being expected to turn other peoples ideas into reality - for free... I've been in more than a few programming forums over my lifetime and virtually none just handed out code upon request... This is one of only a few that has let the practice get out of hand... Trust me, I'm not singling you out personally... Thinkscript really isn't all that hard... I'm more than willing to help those who are willing to help themselves... It would be beneficial in the long run...
 
Ohh thank you rad14733, but unfortunately Im not programmer.
the two codes(same indicator) below helped me learn how to convert trading view code to thinkscript. I am still learning but this helped a lot. Hope this helps get you started.

side note the #(hashtag/pound sign) are non-coding comments. I saw that the code rad14733 supplied has a lot of comments so I wanted you to know you dont have to change any of that text.(unless you want to remove the "#" to make those color statement ect active again)

Code:
Trading View(pinescript I think)

// © racer8
//@version=4
study("Monster Breakout Index",shorttitle="MBI")

per = input(12,title="Period")
H = highest(hl2,per)
hi = H[1]
L = lowest(hl2,per)
lo = L[1]
cl = close
ind = cl>hi? 1 : cl<lo? -1 : 0
c = ind>0? color.lime : ind<0? color.red : color.gray
plot (ind,color=c,style=plot.style_columns)


# Monster Breakout Index (MBI)
# Converted from https://www.tradingview.com/script/nFnRGiCl-Monster-Breakout-Index/
# Assembled by BenTen at UseThinkScript.com

    ThinkScript


declare lower;

input per = 12;
def H = highest(hl2,per);
def hi = H[1];
def L = lowest(hl2,per);
def lo = L[1];
def cl = close;
def ind = if cl>hi then 1 else if cl<lo then -1 else 0;
plot histogram = ind;
histogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
histogram.AssignValueColor(if ind>0 then color.lime else if ind<0 then color.red else color.gray);
 
Last edited:
@JJSPX Can you add a green label for bull trend and a red one for a bear trend?
This is a Tenkan line with the William Alligator used to determine the trend direction. There are other ways to do this, such as a simple uptick downtick scheme.
Code:
input length2 = 9;
input tenkan_period = 9;
input kijun_period = 26;
input cost = close;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;




input price = hl2;
input jawLength = 13;
input teethLength = 8;
input lipsLength = 5;
input jawDisplace = -8;
input teethDisplace = -5;
input lipsDisplace = -3;
input averageType = AverageType.WILDERS;
input ExpAverage = AverageType.EXPONENTIAL;
input hullaverage = AverageType.HULL;

def Jaw = MovingAverage(averageType, price[-jawDisplace], jawLength);
def Teeth = MovingAverage(averageType, price[-teethDisplace], teethLength);
def Lips = MovingAverage(averageType, price[-lipsDisplace], lipsLength);

Tenkan.AssignValueColor(if (Teeth > Jaw or Lips > Jaw) then Color.CYAN else Color.GRAY);
 

arv06

New member
VIP
Hello everyone, I have modified the Ichimoku cloud to provide long and short entry signals based on the YouTube video
. I back tested few and seems to be working, there are some instances where it provides false signals, I will look into eliminating them. If anyone wants to check it out, here is the code


Code:
# Ichimoku Long and Short entry signals based on Youtube video https://www.youtube.com/watch?v=KE_SAzserLE
# By arv06

# For Long Entry - Tenkan should be above Kijun, Chikou should be above the cloud, price should be above the cloud and cloud in front of 26 candles should be green (bullish)

# For Short Entry - Tenkan should be below Kijun, Chikou should be below the cloud, price should be below the cloud and cloud in front of 26 candles should be red (bearish)

input tenkan_period = 9;
input kijun_period = 26;
input showLabels = yes;
input showAlerts = no;
input showBubbles = yes;
input stopLossToTargetRatio=2;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(Color.GREEN);
Tenkan.SetLineWeight(2);

Kijun.SetDefaultColor(Color.RED);
Kijun.SetLineWeight(2);

SpanA.SetDefaultColor(Color.WHITE);
SpanB.SetDefaultColor(Color.YELLOW);

Chikou.SetDefaultColor(Color.MAGENTA);
Chikou.SetLineWeight(2);

DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(SpanA, SpanB, globalColor("Bullish"), globalColor("Bearish"));

def CloudTop = if SpanA > SpanB then SpanA else SpanB;
def CloudBottom = if SpanA > SpanB then SpanB else SpanA;

AddLabel(showLabels, "Price", if close > CloudTop then Color.GREEN else if close==CloudTop then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses below CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Conversion", if Tenkan > Kijun then Color.GREEN else if Tenkan==Kijun then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && Tenkan crosses above Kijun, concat("Conversion Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Tenkan crosses below Kijun, concat("Conversion Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Chikou", if Chikou[kijun_period] > CloudTop[kijun_period] then Color.GREEN else if Chikou[kijun_period] > CloudTop[kijun_period] then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && Chikou[kijun_period] crosses above CloudTop[kijun_period], concat("Chikou Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Chikou[kijun_period] crosses below CloudTop[kijun_period], concat("Chikou Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Cloud", if SpanA[-kijun_period] > SpanB[-kijun_period] then Color.GREEN else if SpanA[-kijun_period]==SpanB[-kijun_period] then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && SpanA[-kijun_period] crosses above SpanB[-kijun_period], concat("Bullish Cloud @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && SpanA[-kijun_period] crosses below SpanB[-kijun_period], concat("Bearish Cloud @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Trade : " + if close > CloudTop then "Long" else if close < CloudBottom then "Short" else "N/A", if close > CloudTop then Color.GREEN else if close < CloudBottom then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses above CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

plot UpSignal = if (Tenkan > Kijun and close > CloudTop and SpanA[-kijun_period] > SpanB[-kijun_period] and Chikou[kijun_period] crosses above CloudTop[kijun_period])
OR (Tenkan > Kijun and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and close crosses above CloudTop)
OR (close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and Tenkan crosses above Kijun)
OR (Tenkan > Kijun and close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] crosses above SpanB[-kijun_period])
then close else Double.Nan;

plot DownSignal = if (Tenkan < Kijun and close < CloudBottom and SpanA[-kijun_period] < SpanB[-kijun_period] and Chikou[kijun_period] crosses below CloudBottom[kijun_period])
OR (Tenkan < Kijun and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and close crosses below CloudBottom)
OR (close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and Tenkan crosses below Kijun)
OR (Tenkan < Kijun and close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] crosses below SpanB[-kijun_period])
then close else Double.Nan;


UpSignal.SetDefaultColor(Color.WHITE);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

AddChartBubble(showBubbles and UpSignal, close, if UpSignal then "SL: " + CloudBottom + ", T: " + (close + ((close - CloudBottom) * stopLossToTargetRatio)) else "N/A", if UpSignal then Color.LIME else Color.CURRENT);

DownSignal.SetDefaultColor(Color.WHITE);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddChartBubble(showBubbles and DownSignal, close, if DownSignal then "SL: " + CloudTop + ", T: " + (close - ((CloudTop - close) * stopLossToTargetRatio)) else  "N/A", if DownSignal then Color.ORANGE else Color.CURRENT);
 

Ahmar824

Member
Hello everyone, I have modified the Ichimoku cloud to provide long and short entry signals based on the YouTube video
. I back tested few and seems to be working, there are some instances where it provides false signals, I will look into eliminating them. If anyone wants to check it out, here is the code


Code:
# Ichimoku Long and Short entry signals based on Youtube video https://www.youtube.com/watch?v=KE_SAzserLE
# By arv06

# For Long Entry - Tenkan should be above Kijun, Chikou should be above the cloud, price should be above the cloud and cloud in front of 26 candles should be green (bullish)

# For Short Entry - Tenkan should be below Kijun, Chikou should be below the cloud, price should be below the cloud and cloud in front of 26 candles should be red (bearish)

input tenkan_period = 9;
input kijun_period = 26;
input showLabels = yes;
input showAlerts = no;
input showBubbles = yes;
input stopLossToTargetRatio=2;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(Color.GREEN);
Tenkan.SetLineWeight(2);

Kijun.SetDefaultColor(Color.RED);
Kijun.SetLineWeight(2);

SpanA.SetDefaultColor(Color.WHITE);
SpanB.SetDefaultColor(Color.YELLOW);

Chikou.SetDefaultColor(Color.MAGENTA);
Chikou.SetLineWeight(2);

DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(SpanA, SpanB, globalColor("Bullish"), globalColor("Bearish"));

def CloudTop = if SpanA > SpanB then SpanA else SpanB;
def CloudBottom = if SpanA > SpanB then SpanB else SpanA;

AddLabel(showLabels, "Price", if close > CloudTop then Color.GREEN else if close==CloudTop then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses below CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Conversion", if Tenkan > Kijun then Color.GREEN else if Tenkan==Kijun then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && Tenkan crosses above Kijun, concat("Conversion Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Tenkan crosses below Kijun, concat("Conversion Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Chikou", if Chikou[kijun_period] > CloudTop[kijun_period] then Color.GREEN else if Chikou[kijun_period] > CloudTop[kijun_period] then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && Chikou[kijun_period] crosses above CloudTop[kijun_period], concat("Chikou Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Chikou[kijun_period] crosses below CloudTop[kijun_period], concat("Chikou Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Cloud", if SpanA[-kijun_period] > SpanB[-kijun_period] then Color.GREEN else if SpanA[-kijun_period]==SpanB[-kijun_period] then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && SpanA[-kijun_period] crosses above SpanB[-kijun_period], concat("Bullish Cloud @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && SpanA[-kijun_period] crosses below SpanB[-kijun_period], concat("Bearish Cloud @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Trade : " + if close > CloudTop then "Long" else if close < CloudBottom then "Short" else "N/A", if close > CloudTop then Color.GREEN else if close < CloudBottom then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses above CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

plot UpSignal = if (Tenkan > Kijun and close > CloudTop and SpanA[-kijun_period] > SpanB[-kijun_period] and Chikou[kijun_period] crosses above CloudTop[kijun_period])
OR (Tenkan > Kijun and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and close crosses above CloudTop)
OR (close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and Tenkan crosses above Kijun)
OR (Tenkan > Kijun and close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] crosses above SpanB[-kijun_period])
then close else Double.Nan;

plot DownSignal = if (Tenkan < Kijun and close < CloudBottom and SpanA[-kijun_period] < SpanB[-kijun_period] and Chikou[kijun_period] crosses below CloudBottom[kijun_period])
OR (Tenkan < Kijun and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and close crosses below CloudBottom)
OR (close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and Tenkan crosses below Kijun)
OR (Tenkan < Kijun and close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] crosses below SpanB[-kijun_period])
then close else Double.Nan;


UpSignal.SetDefaultColor(Color.WHITE);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

AddChartBubble(showBubbles and UpSignal, close, if UpSignal then "SL: " + CloudBottom + ", T: " + (close + ((close - CloudBottom) * stopLossToTargetRatio)) else "N/A", if UpSignal then Color.LIME else Color.CURRENT);

DownSignal.SetDefaultColor(Color.WHITE);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddChartBubble(showBubbles and DownSignal, close, if DownSignal then "SL: " + CloudTop + ", T: " + (close - ((CloudTop - close) * stopLossToTargetRatio)) else  "N/A", if DownSignal then Color.ORANGE else Color.CURRENT);
Thank you!

Try TOS indicator "HeikinAshiDiff" this one is good also.
 
Last edited:

Ahmar824

Member
Hello everyone, I have modified the Ichimoku cloud to provide long and short entry signals based on the YouTube video
. I back tested few and seems to be working, there are some instances where it provides false signals, I will look into eliminating them. If anyone wants to check it out, here is the code


Code:
# Ichimoku Long and Short entry signals based on Youtube video https://www.youtube.com/watch?v=KE_SAzserLE
# By arv06

# For Long Entry - Tenkan should be above Kijun, Chikou should be above the cloud, price should be above the cloud and cloud in front of 26 candles should be green (bullish)

# For Short Entry - Tenkan should be below Kijun, Chikou should be below the cloud, price should be below the cloud and cloud in front of 26 candles should be red (bearish)

input tenkan_period = 9;
input kijun_period = 26;
input showLabels = yes;
input showAlerts = no;
input showBubbles = yes;
input stopLossToTargetRatio=2;

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];

Tenkan.SetDefaultColor(Color.GREEN);
Tenkan.SetLineWeight(2);

Kijun.SetDefaultColor(Color.RED);
Kijun.SetLineWeight(2);

SpanA.SetDefaultColor(Color.WHITE);
SpanB.SetDefaultColor(Color.YELLOW);

Chikou.SetDefaultColor(Color.MAGENTA);
Chikou.SetLineWeight(2);

DefineGlobalColor("Bullish", Color.DARK_GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(SpanA, SpanB, globalColor("Bullish"), globalColor("Bearish"));

def CloudTop = if SpanA > SpanB then SpanA else SpanB;
def CloudBottom = if SpanA > SpanB then SpanB else SpanA;

AddLabel(showLabels, "Price", if close > CloudTop then Color.GREEN else if close==CloudTop then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses below CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Conversion", if Tenkan > Kijun then Color.GREEN else if Tenkan==Kijun then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && Tenkan crosses above Kijun, concat("Conversion Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Tenkan crosses below Kijun, concat("Conversion Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Chikou", if Chikou[kijun_period] > CloudTop[kijun_period] then Color.GREEN else if Chikou[kijun_period] > CloudTop[kijun_period] then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && Chikou[kijun_period] crosses above CloudTop[kijun_period], concat("Chikou Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && Chikou[kijun_period] crosses below CloudTop[kijun_period], concat("Chikou Down @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Cloud", if SpanA[-kijun_period] > SpanB[-kijun_period] then Color.GREEN else if SpanA[-kijun_period]==SpanB[-kijun_period] then Color.LIGHT_GRAY else Color.RED);
Alert(showAlerts && SpanA[-kijun_period] crosses above SpanB[-kijun_period], concat("Bullish Cloud @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && SpanA[-kijun_period] crosses below SpanB[-kijun_period], concat("Bearish Cloud @ $", close), Alert.BAR, Sound.Bell);

AddLabel(showLabels, "Trade : " + if close > CloudTop then "Long" else if close < CloudBottom then "Short" else "N/A", if close > CloudTop then Color.GREEN else if close < CloudBottom then Color.RED else Color.LIGHT_GRAY);
Alert(showAlerts && close crosses above CloudTop, concat("Price Up @ $", close), Alert.BAR, Sound.Bell);
Alert(showAlerts && close crosses above CloudBottom, concat("Price Down @ $", close), Alert.BAR, Sound.Bell);

plot UpSignal = if (Tenkan > Kijun and close > CloudTop and SpanA[-kijun_period] > SpanB[-kijun_period] and Chikou[kijun_period] crosses above CloudTop[kijun_period])
OR (Tenkan > Kijun and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and close crosses above CloudTop)
OR (close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] > SpanB[-kijun_period] and Tenkan crosses above Kijun)
OR (Tenkan > Kijun and close > CloudTop and Chikou[kijun_period] > CloudTop[kijun_period] and SpanA[-kijun_period] crosses above SpanB[-kijun_period])
then close else Double.Nan;

plot DownSignal = if (Tenkan < Kijun and close < CloudBottom and SpanA[-kijun_period] < SpanB[-kijun_period] and Chikou[kijun_period] crosses below CloudBottom[kijun_period])
OR (Tenkan < Kijun and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and close crosses below CloudBottom)
OR (close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] < SpanB[-kijun_period] and Tenkan crosses below Kijun)
OR (Tenkan < Kijun and close < CloudBottom and Chikou[kijun_period] < CloudBottom[kijun_period] and SpanA[-kijun_period] crosses below SpanB[-kijun_period])
then close else Double.Nan;


UpSignal.SetDefaultColor(Color.WHITE);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

AddChartBubble(showBubbles and UpSignal, close, if UpSignal then "SL: " + CloudBottom + ", T: " + (close + ((close - CloudBottom) * stopLossToTargetRatio)) else "N/A", if UpSignal then Color.LIME else Color.CURRENT);

DownSignal.SetDefaultColor(Color.WHITE);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

AddChartBubble(showBubbles and DownSignal, close, if DownSignal then "SL: " + CloudTop + ", T: " + (close - ((CloudTop - close) * stopLossToTargetRatio)) else  "N/A", if DownSignal then Color.ORANGE else Color.CURRENT);
Any updates for this indicator?
 

Similar threads

Top