Ichimoku Price Action

woulf1004

Active member
VIP
Hi Team,

I was trying to create and assign price colors based on tenkan and kijun data using the ichimoku data but could not achieve what I needed.
Can someone use their knowledge to fix this script? I simply need the candles to change colors based on candle closing, like green when the candle closes above tenkan and Kijun, then red when candle closes below kijun and tenkan and finally chance to color gray when candle closes inside or in between tenkan and kijun.


input price = close;
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;

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));

DefineGlobalColor("IchiHigh", color.green); DefineGlobalColor("IchiMid", color.gray); DefineGlobalColor("IchiLow", Color.red);

AssignPriceColor(if close > Tenkan then GlobalColor("IchiHigh") else if close < Kijun then GlobalColor("IchiLow") else GlobalColor("IchiMid"));
 
Hi Team,

I was trying to create and assign price colors based on tenkan and kijun data using the ichimoku data but could not achieve what I needed.
Can someone use their knowledge to fix this script? I simply need the candles to change colors based on candle closing, like green when the candle closes above tenkan and Kijun, then red when candle closes below kijun and tenkan and finally chance to color gray when candle closes inside or in between tenkan and kijun.


input price = close;
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;

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));

DefineGlobalColor("IchiHigh", color.green); DefineGlobalColor("IchiMid", color.gray); DefineGlobalColor("IchiLow", Color.red);

AssignPriceColor(if close > Tenkan then GlobalColor("IchiHigh") else if close < Kijun then GlobalColor("IchiLow") else GlobalColor("IchiMid"));

Optional pricecolor

Capture.jpg
Ruby:
input price = close;
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;

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));

DefineGlobalColor("IchiHigh", color.green); DefineGlobalColor("IchiMid", color.gray); DefineGlobalColor("IchiLow", Color.red);

input pricecolor = yes;
AssignPriceColor(if !pricecolor then color.current
                 else if close > Tenkan and close > Kijun
                 then GlobalColor("IchiHigh")
                 else if close < Kijun and  close < Tenkan
                 then GlobalColor("IchiLow") else GlobalColor("IchiMid"));
 

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

Are you also able to create a script that can plot a moving average line (either simple, exponential, wilders, weighted or hull) with different period settings needed that can change colors based on this ichimoku price action indicator? For example, a 200 EMA that changes colors based on this ichimoku price action indicator results. Oh and also add arrows only on the first closing candles based on the assignpricecolor script provided.
 
Last edited:
Are you also able to create a script that can plot a moving average line (either simple, exponential, wilders, weighted or hull) with different period settings needed that can change colors based on this ichimoku price action indicator? For example, a 200 EMA that changes colors based on this ichimoku price action indicator results. Oh and also add arrows only on the first closing candles based on the assignpricecolor script provided.

Reversed the color profile for the selectable moving average from the bar pricecoloring. Added arrows.

Capture.jpg
Ruby:
#Tenkan_Kijun_Pricecolor_MovAvg_Arrows

input price         = close;
input avgtype       = AverageType.EXPONENTIAL;
input avglength     = 200;
input tenkan_period = 9;
input kijun_period  = 26;

plot MA     = MovingAverage(avgtype, price, avglength);
plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun  = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));
MA.AssignValueColor(if MA < Tenkan and MA < Kijun
                    then GlobalColor("IchiHigh")
                    else if MA > Kijun and  MA > Tenkan
                    then GlobalColor("IchiLow") else GlobalColor("IchiMid"));
MA.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);

DefineGlobalColor("IchiHigh", Color.GREEN);
DefineGlobalColor("IchiMid", Color.GRAY);
DefineGlobalColor("IchiLow", Color.RED);

input pricecolor = yes;
AssignPriceColor(if !pricecolor then Color.CURRENT
                 else if close > Tenkan and close > Kijun
                 then GlobalColor("IchiHigh")
                 else if close < Kijun and  close < Tenkan
                 then GlobalColor("IchiLow") else GlobalColor("IchiMid"));

input showarrows  = yes;

def up = close > Tenkan and close > Kijun;
def dn = close < Kijun and  close < Tenkan;
def neutral = !up or !dn;
def arrowup = CompoundValue(1,
              if !up[1] and up
              then 1
              else if dn
              then 0
              else arrowup[1] + 1, 1);
def arrowdn = CompoundValue(1,
              if !dn[1] and dn
              then 1
              else if up
              then 0
              else arrowdn[1] + 1, 1);

plot uparrow = if showarrows and arrowup == 1 and up then 1 else 0;
uparrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
uparrow.SetLineWeight(5);
uparrow.SetDefaultColor(Color.GREEN);

plot dnarrow = if showarrows and arrowdn == 1 and dn then 1 else 0;
dnarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dnarrow.SetLineWeight(5);
dnarrow.SetDefaultColor(Color.RED);
#
 
Awesome! Are you able to add a bar closing condition so that it won't plot multiple arrows after the first bar? meaning, if in a choppy situation the next arrow can plot after the 3rd or 4th confirmed closed bar?
 
Awesome! Are you able to add a bar closing condition so that it won't plot multiple arrows after the first bar? meaning, if in a choppy situation the next arrow can plot after the 3rd or 4th confirmed closed bar?

The arrows are limited to change whenever going from red to green and vs versa for the most part.
 
I see.. or Is there any way we can have these arrows to plot on the third closing candle instead of the first one maybe? Or will it be the same situation?
 
Last edited:
I see.. or Is there any way we can have these arrows to plot on the third closing candle instead of the first one maybe? Or will it be the same situation?

I redid the arrow counts and used count of 4 to activate the up/down arrows. Just change it to your liking.

Ruby:
#Tenkan_Kijun_Pricecolor_MovAvg_Arrows

input price         = close;
input avgtype       = AverageType.EXPONENTIAL;
input avglength     = 200;
input tenkan_period = 9;
input kijun_period  = 26;

plot MA     = MovingAverage(avgtype, price, avglength);
plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun  = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;

Tenkan.SetDefaultColor(GetColor(1));
Kijun.SetDefaultColor(GetColor(2));
MA.AssignValueColor(if MA < Tenkan and MA < Kijun
                    then GlobalColor("IchiHigh")
                    else if MA > Kijun and  MA > Tenkan
                    then GlobalColor("IchiLow") else GlobalColor("IchiMid"));
MA.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);

DefineGlobalColor("IchiHigh", Color.GREEN);
DefineGlobalColor("IchiMid", Color.GRAY);
DefineGlobalColor("IchiLow", Color.RED);

input pricecolor = yes;
AssignPriceColor(if !pricecolor then Color.CURRENT
                 else if close > Tenkan and close > Kijun
                 then GlobalColor("IchiHigh")
                 else if close < Kijun and  close < Tenkan
                 then GlobalColor("IchiLow") else GlobalColor("IchiMid"));

input showarrows = yes;

def up      = close > Tenkan and close > Kijun;
def dn      = close < Kijun and  close < Tenkan;
def neutral = between(close,min(kijun,tenkan),max(kijun,tenkan));

def x       = CompoundValue(1,
              if x[1]<=0 and (dn[1] or up[1]==0) and up
              then 1
              else if x[1]>=1 and (up or !dn)
              then x[1]+1
              else 0, 1);
def y       = CompoundValue(1,
              if y[1]<=0 and (up[1] or dn[1]==0) and dn
              then 1
              else if y[1]>=1 and (dn or !up)
              then y[1]+1
              else 0, 1);

plot uparrow = if showarrows and x == 4 and up then 1 else 0;
uparrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
uparrow.SetLineWeight(5);
uparrow.SetDefaultColor(Color.yellow);

plot dnarrow = if showarrows and y == 4 and dn then 1 else 0;
dnarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dnarrow.SetLineWeight(5);
dnarrow.SetDefaultColor(Color.white);
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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