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:

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

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

Askia

New 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);
What is SL and what is T:
 

Sorigby

New 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);
I have been using this strategy for a bit and would like to know if there is a way to make a scanner for it? It would make life a little bit easier lol
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
219 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.
Top