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.

You do know your Tenkan and Kijun are the same calculation. How is the Kijun then more powerful?
 
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).
 
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
 
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);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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