Ichimoku [xdecow] For ThinkOrSwim

apdusp

Active member
VIP
The author states:
The Ichimoku Kinko Hyo (Ichimoku Cloud) is a popular indicator / system.
In this version you will have a panel that shows the main signs of this system.
Each signal can have its status as bullish (weak, neutral or strong), consolidation and bearish (weak, neutral or strong).

Signals

Kijun-Sen Cross

Occurs when the price closes above/below the Kijun-sen.
  • Weak Bullish: Occurs below the Kumo.
  • Weak Bearish: Occurs above the Kumo.
  • Bullish/Bearish Neutral: Occurs inside the Kumo.
  • Strong Bullish: Occurs above the Kumo.
  • Strong Bearish: Occurs below the Kumo.

TK Cross
Occurs when the Tenkan-sen crosses the Kijun-sen.
  • Weak Bullish: Occurs when the crossing is below the Kumo.
  • Weak Bearish: Occurs when the crossing is above the Kumo.
  • Bullish/Bearish Neutral: Occurs when the crossing is inside the Kumo.
  • Strong Bullish: Occurs when the crossing is above the Kumo.
  • Strong Bearish: Occurs when the crossing is below the Kumo.

Chikou Span Cross
Occurs when the Chikou Span crosses the price.
  • Weak Bullish: Occurs when current price is below the Kumo.
  • Weak Bearish: Occurs when current price is above the Kumo.
  • Bullish/Bearish Neutral: Occurs when current price is inside the Kumo.
  • Strong Bullish: Occurs when current price is above the Kumo.
  • Strong Bearish: Occurs when current price is below the Kumo.

Kumo Breakout
Occurs when the price closes above/below the Kumo.

Kumo Twist
Occurs when the Senkou Span A crosses the Senkou Span B ahead.
  • Weak Bullish: Occurs when current price is below the Kumo.
  • Weak Bearish: Occurs when current price is above the Kumo.
  • Bullish/Bearish Neutral: Occurs when current price is inside the Kumo.
  • Strong Bullish: Occurs when current price is above the Kumo.
  • Strong Bearish: Occurs when current price is below the Kumo.


In addition, Senkou Span B turns golden when it is flat and the cloud is lighter when it is thin (default is half the average of the last 610).
Fb078gZ.png



Could you please convert this TV indicator ( https://www.tradingview.com/script/00PhYhFi-Ichimoku-xdecow/ ) , which in particular improves the visual and is just a few centimeters away from the addition of scanning features based on the crossing signals it provides.
Thanks in advance
 
Last edited by a moderator:

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

Could you please convert this TV indicator ( https://www.tradingview.com/script/00PhYhFi-Ichimoku-xdecow/ ) , which in particular improves the visual and is just a few centimeters away from the addition of scanning features based on the crossing signals it provides.
Thanks in advance
check the below

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © xdecow
#study("Ichimoku [xdecow]", overlay=true)
# Converted by Sam4Cok@Samer800    - 02/2024

input ShowPanel     = yes;#(true, 'Show panel')
input ColoredBars    = no;#(false, 'Colored bars')
input KumoThicknessAvgLength = 610;#, 'Kumo Thickness AVG Length', minval=2)
input KumoThicknessAvgRatio  = 0.5; #, 'Kumo Thickness AVG Ratio')
input preset = {default "Custom", "9/26/52/26     - 6D Markets (Default)", "8/22/44/22     - 5D Markets", "9/30/60/30     - 24h/7D Markets (Crypto)", "20/60/120/60   - 24h/7D Markets (Slow Version)"}; # "Preset"
input customTenkanSenLength   = 9;  #, minval=2, title="Tenkan-sen Length", group="Custom", tooltip="Conversion Line")
input customKijunSenLength    = 26; #, minval=2, title="Kijun-sen Length", group="Custom", tooltip="Base Line")
input customChikouSpanLength  = 52; #, minval=2, title="Chikou Span Length", group="Custom", tooltip="Lagging Span")
input customOffset            = 26; #, minval=0, title="Offset", group="Custom")
input KijunSenCross   = yes;     # 'Kijun-sen Cross'
input TenkanSenCross  = yes;     # 'TK Cross',
input ChikouSpanCross = yes;     # 'Chikou Span Cross',
input KumoBreakout    = yes;     # 'Kumo Breakout',
input KumoTwistCross  = yes;     # 'Kumo Twist'

def na = Double.NaN;
def bar = BarNumber();
#// Barcolor
DefineGlobalColor("lagging",  CreateColor(129, 199, 132));
DefineGlobalColor("conversion",  CreateColor(0, 188, 212));
DefineGlobalColor("base",  CreateColor(255, 82, 82));
DefineGlobalColor("lead2",  Color.GRAY);
DefineGlobalColor("lead2flat",  CreateColor(255,183,77));
DefineGlobalColor("cons", CreateColor(208,119,0));
DefineGlobalColor("up1", CreateColor(56,142,60));
DefineGlobalColor("up2", CreateColor(102,187,106));
DefineGlobalColor("up3", CreateColor(165,214,167));
DefineGlobalColor("dn1", CreateColor(211,47,47));
DefineGlobalColor("dn2", CreateColor(239,83,80));
DefineGlobalColor("dn3", CreateColor(239,154,154));

#// Funcs
script addSignal {
    input enabled = yes;
    input signal  = 0;
    def addSignal = if enabled then signal else Double.NaN;
    plot out = addSignal;
}
script donchian {
    input len = 9;
    def hh = Highest(high, len);
    def ll = Lowest(low, len);
    def donchian = (ll + hh) / 2;
    plot out = donchian;
}
script getCloudTrend {
    input l1 = close;
    input l2 = close;
    def getCloudTrend = if l1 > l2 then 1 else -1;
    plot out = getCloudTrend;
}
script getPositionStrength {
    input pos = 0;
    input uptrend = yes;
    def getPositionStrength = if uptrend then if pos == 1 then 1 else if pos == 0 then 2 else 3 else
                              if pos == -1 then -1 else if pos == 0 then -2 else -3;
    plot out = getPositionStrength;
}
def i_conversion_len;
def i_base_len;
def i_lagging_len;
def i_offset;
switch (preset) {
case "9/26/52/26     - 6D Markets (Default)" :
    i_conversion_len = 9;
    i_base_len = 26;
    i_lagging_len = 52;
    i_offset = 26;
case "8/22/44/22     - 5D Markets" :
    i_conversion_len = 5;
    i_base_len = 22;
    i_lagging_len = 44;
    i_offset = 22;
case "9/30/60/30     - 24h/7D Markets (Crypto)" :
    i_conversion_len = 10;
    i_base_len = 30;
    i_lagging_len = 60;
    i_offset = 30;
case "20/60/120/60   - 24h/7D Markets (Slow Version)" :
    i_conversion_len = 20;
    i_base_len = 60;
    i_lagging_len = 120;
    i_offset = 60;
default :
    i_conversion_len = customTenkanSenLength;
    i_base_len = customKijunSenLength;
    i_lagging_len = customChikouSpanLength;
    i_offset = customOffset;
}
def n = i_offset - 1;
#// Calcs
def i_conversion = donchian(i_conversion_len);
def i_base       = donchian(i_base_len);
def i_lead1      = (i_conversion + i_base) / 2;
def i_lead2      = donchian(i_lagging_len);
def i_cloud_top2 = Max(i_lead1, i_lead2);
def i_cloud_bot2 = Min(i_lead1, i_lead2);

#// kumo thickness
def sma = Average((i_cloud_top2 - i_cloud_bot2) * KumoThicknessAvgRatio, KumoThicknessAvgLength);
def i_cloud_thick_limit = i_cloud_bot2 + sma;
#// leading line at candle position
def i_lead1_current = i_lead1[n];
def i_lead2_current = i_lead2[n];
def i_cloud_top = Max(i_lead1_current, i_lead2_current);
def i_cloud_bot = Min(i_lead1_current, i_lead2_current);

#// position relative to kumo cloud
def s_base_position = if i_base > i_cloud_top then 1 else if i_base < i_cloud_bot then -1 else 0;
def s_base_breakout = if close > i_base then getPositionStrength(s_base_position, yes) else
                                             getPositionStrength(s_base_position, no);
def Sig1 = addSignal(KijunSenCross, s_base_breakout);
#// cloud 2
def s_cloud2_trend = getCloudTrend(i_conversion, i_base);
def s_cloud2_top = Max(i_base, i_conversion);
def s_cloud2_bot = Min(i_base, i_conversion);
#// position relative to kumo cloud
def s_cloud2_position = if s_cloud2_bot > i_cloud_top then 1 else if s_cloud2_top < i_cloud_bot then -1 else 0;
def s_cloud2_cross = if s_cloud2_trend == 1 then getPositionStrength(s_cloud2_position, yes) else
                                                 getPositionStrength(s_cloud2_position, no);
def sig2 = addSignal(TenkanSenCross, s_cloud2_cross);
#// lagging span
#// cloud at lagging span
def s_lagging_lead1 = i_lead1_current[n];
def s_lagging_lead2 = i_lead2_current[n];
def s_lagging_cloud_top   = Max(s_lagging_lead1, s_lagging_lead2);
def s_lagging_cloud_bot   = Min(s_lagging_lead1, s_lagging_lead2);
#// closing value of current lagging span bar
def s_lagging_high = high[i_offset - 1];
def s_lagging_low = low[i_offset - 1];
def s_lagging_trend = if close > s_lagging_high then 1 else if close < s_lagging_low then -1 else 0;
#// s_lagging_position = close > s_lagging_cloud_top ? 1 :
def s_lagging_position = if close > i_cloud_top then 1 else if close < i_cloud_bot then -1 else 0;
def s_lagging_cross = if s_lagging_trend == 1 then getPositionStrength(s_lagging_position, yes) else
                      if s_lagging_trend == -1 then getPositionStrength(s_lagging_position, no) else 0;
def sig3 = addSignal(ChikouSpanCross, s_lagging_cross);
#// cloud breakout
def s_cloud_breakout = if close > i_cloud_top then 1 else if close < i_cloud_bot then -1 else 0;
def sig4 = addSignal(KumoBreakout, s_cloud_breakout);
#// leading cross
def s_cloud_trend = getCloudTrend(i_lead1, i_lead2);
def s_lead_cross = if s_cloud_trend == 1 then getPositionStrength(s_cloud_breakout, yes) else
                                              getPositionStrength(s_cloud_breakout, no);
def sig5 = addSignal(KumoTwistCross, s_lead_cross);
def sigUp1 = if isNaN(sig1) then 0 else sig1;
def sigUp2 = if isNaN(sig2) then 0 else sig2;
def sigUp3 = if isNaN(sig3) then 0 else sig3;
def sigUp4 = if isNaN(sig4) then 0 else sig4;
def sigUp5 = if isNaN(sig5) then 0 else sig5;
def sigdn1 = if isNaN(sig1) then 5 else sig1;
def sigdn2 = if isNaN(sig2) then 5 else sig2;
def sigdn3 = if isNaN(sig3) then 5 else sig3;
def sigdn4 = if isNaN(sig4) then 5 else sig4;
def sigdn5 = if isNaN(sig5) then 5 else sig5;
#/ final signal
def s_signal_min = min(sigdn1, min(sigdn2, min(sigdn3, min(sigdn4, sigdn5))));
def s_signal_max = max(sigUp1, max(sigUp2, max(sigUp3, max(sigUp4, sigUp5))));
def s_signal = if s_signal_min > 0 then s_signal_max else
               if s_signal_max < 0 then s_signal_min else 0;
#// Plots
#// Cloud
def i_cloud_color = if s_cloud_trend == 1 then
                    if isNaN(i_cloud_thick_limit) or i_cloud_top2 > i_cloud_thick_limit then 2 else 1 else
                    if isNaN(i_cloud_thick_limit) or i_cloud_top2 > i_cloud_thick_limit then -2 else -1;
def cloudClo = i_cloud_color[n];
def i_cloud_p1 = i_lead1[n]; # color=c_lead1, title="Senkou Span A"

plot i_cloud_p2 = i_lead2[n]; # color=i_lead2 == i_lead2[1] ? c_lead2_flat : c_lead2, linewidth=2, title='Senkou Span B')
plot i_cloud2_p1 = i_conversion; #, color=c_conversion, title="Tenkan-sen", linewidth=2)
plot i_cloud2_p2 = i_base; #, color=c_base, title="Kijun-sen", linewidth=2)
plot ChikouLine = close[-n]; #, offset=-i_offset + 1, color=c_lagging, title="Chikou Span", linewidth=2)

i_cloud_p2.SetLineWeight(2);
i_cloud2_p1.SetLineWeight(2);
ChikouLine.SetLineWeight(2);
i_cloud_p2.AssignValueColor(if i_cloud_p2 == i_cloud_p2[1] then GlobalColor("lead2flat") else GlobalColor("lead2"));
i_cloud2_p1.SetDefaultColor(GlobalColor("conversion"));
i_cloud2_p2.SetDefaultColor(GlobalColor("base"));
ChikouLine.SetDefaultColor(GlobalColor("lagging"));

AddCloud(if cloudClo==2 or cloudClo[-1]==2 then i_cloud_p1 else na, i_cloud_p2, Color.LIGHT_GREEN);
AddCloud(if cloudClo==1 or cloudClo[-1]==1 then i_cloud_p1 else na, i_cloud_p2, Color.DARK_GREEN);
AddCloud(if cloudClo==-2 or cloudClo[-1]==-2 then i_cloud_p2 else na, i_cloud_p1, Color.LIGHT_RED);
AddCloud(if cloudClo==-1 or cloudClo[-1]==-1 then i_cloud_p2 else na, i_cloud_p1, Color.DARK_RED);

#// signals

AddLabel(ShowPanel and KijunSenCross, "Kijun-sen Cross (" +
          if s_base_breakout == 1 then "Strong)" else
          if s_base_breakout == 2 then "Neutral)" else
          if s_base_breakout == 3 then "Weak)" else
          if s_base_breakout ==-1 then "Strong)" else
          if s_base_breakout ==-2 then "Neutral)" else
          if s_base_breakout ==-3 then "Weak)" else "Consolidation)",
          if s_base_breakout == 1 then GlobalColor("up1") else
          if s_base_breakout == 2 then GlobalColor("up2") else
          if s_base_breakout == 3 then GlobalColor("up3") else
          if s_base_breakout ==-1 then GlobalColor("dn1") else
          if s_base_breakout ==-2 then GlobalColor("dn2") else
          if s_base_breakout ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
AddLabel(ShowPanel and TenkanSenCross, "TK Cross (" +
          if s_cloud2_cross == 1 then "Strong)" else
          if s_cloud2_cross == 2 then "Neutral)" else
          if s_cloud2_cross == 3 then "Weak)" else
          if s_cloud2_cross ==-1 then "Strong)" else
          if s_cloud2_cross ==-2 then "Neutral)" else
          if s_cloud2_cross ==-3 then "Weak)" else "Consolidation)",
          if s_cloud2_cross == 1 then GlobalColor("up1") else
          if s_cloud2_cross == 2 then GlobalColor("up2") else
          if s_cloud2_cross == 3 then GlobalColor("up3") else
          if s_cloud2_cross ==-1 then GlobalColor("dn1") else
          if s_cloud2_cross ==-2 then GlobalColor("dn2") else
          if s_cloud2_cross ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
AddLabel(ShowPanel and ChikouSpanCross, "Chikou Span Cross (" +
          if s_lagging_cross == 1 then "Strong)" else
          if s_lagging_cross == 2 then "Neutral)" else
          if s_lagging_cross == 3 then "Weak)" else
          if s_lagging_cross ==-1 then "Strong)" else
          if s_lagging_cross ==-2 then "Neutral)" else
          if s_lagging_cross ==-3 then "Weak)" else "Consolidation)",
          if s_lagging_cross == 1 then GlobalColor("up1") else
          if s_lagging_cross == 2 then GlobalColor("up2") else
          if s_lagging_cross == 3 then GlobalColor("up3") else
          if s_lagging_cross ==-1 then GlobalColor("dn1") else
          if s_lagging_cross ==-2 then GlobalColor("dn2") else
          if s_lagging_cross ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
AddLabel(ShowPanel and KumoBreakout, "Kumo Breakout (" +
          if s_cloud_breakout == 1 then "Strong)" else
          if s_cloud_breakout == 2 then "Neutral)" else
          if s_cloud_breakout == 3 then "Weak)" else
          if s_cloud_breakout ==-1 then "Strong)" else
          if s_cloud_breakout ==-2 then "Neutral)" else
          if s_cloud_breakout ==-3 then "Weak)" else "Consolidation)",
          if s_cloud_breakout == 1 then GlobalColor("up1") else
          if s_cloud_breakout == 2 then GlobalColor("up2") else
          if s_cloud_breakout == 3 then GlobalColor("up3") else
          if s_cloud_breakout ==-1 then GlobalColor("dn1") else
          if s_cloud_breakout ==-2 then GlobalColor("dn2") else
          if s_cloud_breakout ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
AddLabel(ShowPanel and KumoTwistCross, "Kumo Twist (" +
          if s_lead_cross == 1 then "Strong)" else
          if s_lead_cross == 2 then "Neutral)" else
          if s_lead_cross == 3 then "Weak)" else
          if s_lead_cross ==-1 then "Strong)" else
          if s_lead_cross ==-2 then "Neutral)" else
          if s_lead_cross ==-3 then "Weak)" else "Consolidation)",
          if s_lead_cross == 1 then GlobalColor("up1") else
          if s_lead_cross == 2 then GlobalColor("up2") else
          if s_lead_cross == 3 then GlobalColor("up3") else
          if s_lead_cross ==-1 then GlobalColor("dn1") else
          if s_lead_cross ==-2 then GlobalColor("dn2") else
          if s_lead_cross ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
AddLabel(ShowPanel, "Signal (" +
          if s_signal == 1 then "Strong)" else
          if s_signal == 2 then "Neutral)" else
          if s_signal == 3 then "Weak)" else
          if s_signal ==-1 then "Strong)" else
          if s_signal ==-2 then "Neutral)" else
          if s_signal ==-3 then "Weak)" else "Consolidation)",
          if s_signal == 1 then GlobalColor("up1") else
          if s_signal == 2 then GlobalColor("up2") else
          if s_signal == 3 then GlobalColor("up3") else
          if s_signal ==-1 then GlobalColor("dn1") else
          if s_signal ==-2 then GlobalColor("dn2") else
          if s_signal ==-3 then GlobalColor("dn3") else GlobalColor("cons"));
#    trend > 0 ? c_up : trend < 0 ? c_down : c_consolidation
def bCol = if s_signal > 0 then 1 else
           if s_signal < 0 then -1 else 0;

AssignPriceColor(if !ColoredBars then Color.CURRENT else
                 if close > open then
                 if bCol > 0 then Color.GREEN else
                 if bCol < 0 then Color.DARK_RED else Color.DARK_GRAY else
                 if bCol > 0 then Color.DARK_GREEN else
                 if bCol < 0 then Color.RED else Color.GRAY);

#-- END of CODE
 
wtf!!! I have no words for your strikingly fast reply. Insomnia? When you come back to Mars, give me a call and we can get a strong coffee. Thanks you, once more !!

on other matters, I superimposed the TOS built-in Ichimoku indicator and there is a shift on the cloud and lines, except for Tenkan and Kinjan lines. I checked in TV and also compared with the built in Ichimoku indicator and there was no such shifts.
 
Just for fun(??) for Ichimoku fans, check using this indicator with the also @samer800 wonderful conversion, https://usethinkscript.com/threads/ichimoku-oscillator-lonesometheblue-for-thinkorswim.17955/ for a more quantified perception, though some parameters might need to change according on either or both indicators.

PS: the author of the oscillator, LonesomeTheBlue, prefers a (8,13,26,13) setup instead of the standard (9,26,52,26). In his words "as far as I see these settings are better, to catch all moves faster", though of course it all depends on user preferences.​

 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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