Ichmoku Study Needing a little fix

Chuck

Well-known member
This study is great but it has a little error in it "Invalid statement: def at 221:1"

Could I get one of you guys to fix it?

Code:
##Hint:This Ichmoku study has many signals. Some are more important/controlling than others. This study allows you to select the type of signal you are interested in, the strength level of those signals and the Bullish or Bearish sentiment.The appropriate arrows will be plotted with optional bubbles to identify the signal strength and bull/bear.
# TOS title = 'Ichi_Signals' by StanL version 1.0
#USAGE NOTES: !.All Bullish signals are UP arrows of cyan coloring. All Bearish signals are DOWN arrows of magenta coloring.
#2.Bubbles may be toggled OFF to avoid chart clutter. All bubbles are colored white for readability.
#3.Selectable inputs for arrow plotting are:1. Each of the 5 Ichimoku parameters(lines); 2.Signal strengths of Strong, neutral, weak or All;3.Bullish, Bearish or All.
# The main Ichimoku signals to monitor, in order of importance, are:
#   1. Price vs Cloud (the 'big picture')
#   2. Price vs Tenkan/Kijun
#   3. Momentum
#   4. Future Cloud
#These signals are not 'stand alone' for decision making and must be evaluated using other related ichimoku data as well as other external studies and indicators.
#A free detailed reference, 'Ichmoku E-Book', is available at [URL]https://www.ichimokutrade.com/c/videos/categories/ichimoku-videos/[/URL] as well as a tutorial at [URL]http://www.kumotrader.com/ichimoku_wiki/index.php?title=Ichimoku_components[/URL]
#The E-Book has details for developing buy/sell strategies using the Ichimoku signals.

input ShowBubbles = yes;#Hint ShowBubbles:Toggles bubbles ON/OFF
input ShowColorLabels = Yes;#hint ShowColorLabels:Toggles the color coding labels ON/OFF
input tenkan_period = 9;#Hint tenkan_period: The number of bars used to calculate the Tenkan cyan plot. Default is 9. Change of this value is not recommended.
input kijun_period = 26;#Hint kijun_period: The number of bars used to calculate the Kijun pink plot. Default is 26. Change of this value is not recommended.
input Type_Signal = {default "T/K Cross", "Kijun Cross", "Cloud BreakOut", "SpanA/B Cross", "Chikou Cross"};#Hint Type_Signal:Select the type of signal to show. All is not a choice because there would be too many signals to show. Each choice could have up to 6 signals i.e. Bullish/Bearish, Strong, Neutral & Weak signals.
input Signal_strength = {default Strong, Neutral, Weak, All};#hint Signal_strength:Show only signals having the strength selected
input Bullish_Bearish = {default Bullish, Bearish, Both};#hint Bullish_Bearish:Select the orientation desired

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];
Tenkan.SetDefaultColor(GetColor(1));
#Kijun.SetDefaultColor(GetColor(2));
"Span A".SetDefaultColor(GetColor(3));
"Span B".SetDefaultColor(GetColor(4));
Chikou.SetDefaultColor(GetColor(5));
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Span A", "Span B", GlobalColor("Bullish"), GlobalColor("Bearish"));

#=== Define global colors ===
# aqua is Bullish & ARROW_UP
DefineGlobalColor("BullStrong", CreateColor(82, 242, 234));#light aqua
DefineGlobalColor("BullNeutral", CreateColor(155, 215, 213));#medium aqua
DefineGlobalColor("BullWeak", CreateColor(36, 179, 172));#dark aqua
#magenta tint is Bearish & ARROW_DOWN
DefineGlobalColor("BearStrong", CreateColor(255, 0, 255));#light = magenta
DefineGlobalColor("BearNeutral", CreateColor(221, 160, 221));#medium plum
DefineGlobalColor("BearWeak", CreateColor(186, 85, 211));#med orchid
#DefineGlobalColor("Global1", CreateColor(128, 0, 128));
#?.SetDefaultColor(GlobalColor("?"));

#=== BASIC CONDITIONS ====
def IsAboveCloud = if close > Ichimoku()."Span A" && close > Ichimoku()."Span B" then 1 else 0; # close is above the cloud
def IsBelowCloud = if close < Ichimoku()."Span A" && close < Ichimoku()."Span B" then 1 else 0; # close is below the cloud
def IsInCloud = if (("Span A" > "Span B" && close[0] < "Span A" && close[0] > "Span B") or ("Span B" > "Span A" &&
close[0] > "Span A" && close[0] < "Span B"),1,0);#This code has been analyzed & proven accurate
#def IsInCloud = If close > Min(Ichimoku()."Span A",Ichimoku()."Span B") && close < Max(Ichimoku()."SpanA",Ichimoku()."Span B") then 1 else 0;# Close is in the cloud
#def IsInCloud = if close > Min("Span A", "Span B") && close < Max("Span A", "Span B") then 1 else 0;# Close is in the cloud
def want_Strong = if Signal_strength == Signal_strength."Strong" or Signal_strength == Signal_strength."All" then 1 else 0;
def  want_Neutral = if Signal_strength == Signal_strength."Neutral" or Signal_strength == Signal_strength."All" then 1 else 0;
def  want_Weak = if Signal_strength == Signal_strength."Weak" or Signal_strength == Signal_strength."All" then 1 else 0;
def want_Bull = if Bullish_Bearish == Bullish_Bearish."Bullish" or  Bullish_Bearish == Bullish_Bearish."Both" then 1 else 0;
def want_Bear = if Bullish_Bearish == Bullish_Bearish."Bearish" or  Bullish_Bearish == Bullish_Bearish."Both" then 1 else 0
;
###############################################
#==== TENKAN/KIJUN (T/K) CROSS SIGNALS ====   #
#The tenkan/kijun cross is one of the most traditional trading strategies within the Ichimoku system.

###############################################
def Is_TKC = if  Type_Signal == Type_Signal."T/K Cross" then 1 else 0;
#=== === Bullish SIGNALS == T crosses above the K ====
#===================================================
#===      === Strong T/K Bullish cross happens while ABOVE the cloud ===
def cond_STK = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsAboveCloud;

plot STK_Cross = If (cond_STK && Is_TKC &&  want_Strong && want_Bull , Tenkan, Double.NaN);
STK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
STK_Cross.SetLineWeight(5);
STK_Cross.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && cond_STK && Is_TKC &&  want_Strong && want_Bull , Tenkan, "Strong\nBullish", Color.WHITE, yes);

###=== NEUTRAL T/K cross(NTKC)happens while IN the cloud ===
def cond_NTKC = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsInCloud;

plot NTK_Cross = If(cond_NTKC && Is_TKC &&  want_Neutral && want_Bull , Tenkan, Double.NaN);
NTK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
NTK_Cross.SetLineWeight(5);
NTK_Cross.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && cond_NTKC && Is_TKC && want_Neutral && want_Bull , Tenkan, "Neutral\nBullish", Color.WHITE, yes);

###=== WEAK cross T/K(WTKC) happens while BELOW the cloud ===
def cond_WTKC = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsBelowCloud;

plot WTK_Cross = If(cond_NTKC && Is_TKC && want_Bull && want_Weak, Tenkan, Double.NaN);
WTK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
WTK_Cross.SetLineWeight(5);
WTK_Cross.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && cond_NTKC && Is_TKC && want_Bull && want_Weak, Tenkan, "Weak\nBullish", Color.WHITE, yes);

##=== Bearish SIGNALS == T crosses below the K (K/T)====
##############################################
#===      === Strong K/T Bearish cross happens while BELOW the cloud===
def cond_SKT_Cross = Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsBelowCloud;

plot SKT_Cross = If(cond_SKT_Cross && Is_TKC &&  want_Strong && want_Bear, Tenkan, Double.NaN);
SKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SKT_Cross.SetLineWeight(5);
SKT_Cross.SetDefaultColor(CreateColor(255, 0, 255));

AddChartBubble(ShowBubbles &&  cond_SKT_Cross && Is_TKC &&  want_Strong && want_Bear , Tenkan, "Strong\nBearish",  Color.WHITE, yes);

###=== NEUTRAL cross K/T happens while IN the cloud ===
def cond_NKT_Cross =  Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsInCloud;

plot NKT_Cross =  If(cond_NKT_Cross && Is_TKC && want_Neutral && want_Bear, Tenkan, Double.NaN);
NKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
NKT_Cross.SetLineWeight(5);
NKT_Cross.SetDefaultColor(CreateColor(221, 160, 221));

AddChartBubble(ShowBubbles && cond_NKT_Cross && Is_TKC && want_Neutral && want_Bear , Tenkan, "Neutral\nBearish",  Color.WHITE, yes);

#===      === WEAK cross K/T happens while ABOVE the cloud  ===
def Cond_WKT_Cross = Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsAboveCloud;

plot WKT_Cross = If (Cond_WKT_Cross && Is_TKC && want_Weak && want_Bear, Tenkan, Double.NaN);
WKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
WKT_Cross.SetLineWeight(5);
WKT_Cross.SetDefaultColor(CreateColor(186, 85, 211));

AddChartBubble(ShowBubbles && Cond_WKT_Cross && Is_TKC && want_Weak && want_Bear , Tenkan,"Weak\nBearish",  Color.WHITE, no);

#####################################
#==== KIJUN CROSS SIGNALS ====     ##
#The kijun cross is one of the most powerful and reliable trading strategies within the Ichimoku system. It can be used on nearly all time frames with excellent results, though it will be somewhat less reliable on the lower, daytrading time frames due to the increased volatility on those time frames.
#####################################
def is_KC = if Type_Signal == Type_Signal."Kijun Cross" then 1 else 0;
#=== === Bullish SIGNALS when close crosses above the Kijun
#######################################
#===      === BULL & Strong ===
def is_KC_bull_Strong = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsAboveCloud;

plot KC_Strong_Bull = If (is_KC_bull_Strong && is_KC &&  want_Strong && want_Bull, Kijun, Double.NaN);
KC_Strong_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_Strong_Bull.SetLineWeight(5);
KC_Strong_Bull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_KC_bull_Strong && is_KC &&  want_Strong && want_Bull , Kijun, "Strong\nBullish",Color.WHITE, yes);

#===      === BULL & NEUTRAL ===
def is_KC_bull_neutral = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsInCloud;

plot KC_neutral_Bull = If (is_KC_bull_neutral && is_KC && want_Neutral && want_Bull, Kijun, Double.NaN);
KC_neutral_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_neutral_Bull.SetLineWeight(5);
KC_neutral_Bull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_KC_bull_neutral && is_KC && want_Neutral && want_Bull , Kijun, "Neutral\nBullish", Color.WHITE, yes);

#===      === BULL & WEAK ===
def is_KC_bull_weak = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsBelowCloud;

plot KC_weak_Bull = If (is_KC_bull_weak && is_KC && want_Weak && want_Bull, Kijun, Double.NaN);
KC_weak_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_weak_Bull.SetLineWeight(5);
KC_weak_Bull.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && is_KC_bull_weak && is_KC && want_Weak && want_Bull , Kijun, "weak\nBullish",Color.WHITE, yes);

#=== === Bearish SIGNALS when close crosses below the Kijun
####################################
#===      === BEAR & Strong ===
def is_KC_bear_Strong = Crosses(close, Kijun, CrossingDirection.BELOW) && IsBelowCloud;

plot KC_Strong_Bear = If (is_KC_bear_Strong && is_KC &&  want_Strong && want_Bear, Kijun, Double.NaN);
KC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_Strong_Bear.SetLineWeight(5);
KC_Strong_Bear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && is_KC_bear_Strong && is_KC &&  want_Strong && want_Bear , Kijun,"Strong\nBearish",  Color.WHITE, yes);

#===      === BEAR & NEUTRAL ===
def is_KC_bear_neutral = Crosses(close, Kijun, CrossingDirection.BELOW) && IsInCloud;

plot KC_neutral_Bear = If (is_KC_bear_neutral && is_KC && want_Neutral && want_Bear, Kijun, Double.NaN);
KC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_Strong_Bear.SetLineWeight(5);
KC_Strong_Bear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && is_KC_bear_neutral && is_KC && want_Neutral && want_Bear, Kijun, "neutral\nBearish",  Color.WHITE, yes);

#===      === BEAR & WEAK ===
def is_KC_bear_weak = Crosses(close, Kijun, CrossingDirection.BELOW) && IsAboveCloud;

plot KC_weak_Bear = If (is_KC_bear_weak && is_KC && want_Weak && want_Bear, Kijun, Double.NaN);
KC_weak_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_weak_Bear.SetLineWeight(5);
KC_weak_Bear.SetDefaultColor(GlobalColor("Bearweak"));

AddChartBubble(ShowBubbles && is_KC_bear_weak && is_KC && want_Weak && want_Bear, Kijun, "weak\nBearish", Color.WHITE, yes);

#################################
#==== CLOUD BREAKOUT SIGNALS ====  ##
#CLOUD BREAKOUT trading is a trading strategy that can be used on multiple time frames, though it is most widely used on the higher time frames (e.g.: Daily, Weekly, Monthly). CLOUD breakout trading is the purest form of trend trading offered by the Ichimoku charting system, as it looks solely to the CLOUD and price's(close) relationship to it for its signals. It is "big picture" trading that focuses only on whether price is trading above or below the prevailing CLOUD. . In a nutshell, the signal to go long in CLOUD BREAKOUT trading is when price closes above the prevailing CLOUD and, likewise, the signal to go short is when price closes below the prevailing CLOUD.

#############################
def is_CBO = if Type_Signal == Type_Signal."Cloud BreakOut" then 1 else 0;
#=== === Bullish SIGNALS ===
###########################
#A Bullish signal is present when the close moves above the cloud. Caution is needed if close is rising above a flat-top- cloud (a persistent resistance). The position of the close related to the cloud is the most controlling aspect of signal evaluation.....it is the 'Big Picture'.
def SpanA_OnTop = if ("Span A" > "Span B",1,0);
def isCBO_bull_aboveA = if "Span A" > "Span B" && crosses(close,"Span A",CrossingDirection.ABOVE) then 1 else 0;
def isCBO_bull_aboveB = if "Span B" > "Span A" && crosses(close,"Span B",CrossingDirection.ABOVE) then 1 else 0;

plot CBO_Bull_Strong = if (isCBO_bull_aboveA or isCBO_bull_aboveB) && is_CBO &&  want_Strong && want_Bull then close else Double.Nan;
CBO_Bull_Strong.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CBO_Bull_Strong.SetLineWeight(5);
CBO_Bull_Strong.SetDefaultColor(GlobalColor("BullStrong"));

#######THE CODE BELLOW MAY NEED FIXING KIP #########

def is_FlatTop = If (isCBO_bull_cross && SpanA_OnTop && Sum("Span A" > .90 * "Span A"[1], 8) >= 5, 1, 0) orif isCBO_bull_cross && !SpanA_OnTop && sum("Span B" > .95 * "Span B"[1],8) >= 5 ,1,0);
def SpanA_FlatTop = If (isCBO_bull_cross && SpanA_OnTop && Sum("Span A" ==  "Span A"[1], 8) >= 5, 1, 0);
def SpanB_FlatTop = If (isCBO_bull_cross && !SpanA_OnTop && Sum("Span B" ==  "Span B"[1], 8) >= 5, 1, 0);
AddChartBubble(ShowBubbles && (isCBO_bull_aboveA or isCBO_bull_aboveB) && is_CBO &&  want_Strong && want_Bull,close,"Strong\nBullish", Color.WHITE, yes);

#=== === Bearish SIGNALS ===
###########################
#===      === BEAR & Strong ===
def isCBO_Strong_bearA = if "Span A" < "Span B" && crosses(close,"Span A",CrossingDirection.BELOW) then 1 else 0;
def isCBO_Strong_bearB = if "Span B" < "Span A" && crosses(close,"Span B",CrossingDirection.BELOW) then 1 else 0;
plot CBO_Bear_Strong = if (isCBO_Strong_bearA or isCBO_Strong_bearB) && is_CBO &&  want_Strong && want_Bear then close else Double.Nan;
CBO_Bear_Strong.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CBO_Bear_Strong.SetLineWeight(5);
CBO_Bear_Strong.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && (isCBO_Strong_bearA or isCBO_Strong_bearB) && is_CBO &&  want_Strong && want_Bear,close,"Strong\nBearish", Color.WHITE, yes);
##################################################
#==== 'SPAN A' & 'SPAN B' CROSS SIGNALS (SpanAD)====     ###
#The 'Span A' and 'Span B' cross is one of the lesser known trading strategies within the Ichimoku system. This is mostly due to the fact that the 'Span A' cross tends to be more commonly used as an additional confirmation with other trading strategies rather than being used as a standalone trading strategy in its own right. it is best employed on the longer time frames of the Daily chart and above. Keep in mind with the Span crossings is that the "cross" signal will take place 26 periods ahead of the price action as the CLOUD is time-shifted 26 periods into the future.

##################################################
def is_SpanAB = if Type_Signal == Type_Signal."SpanA/B Cross" then 1 else 0;

#=== === Bullish SIGNALS ===
###########################
#===   === SpanAB BULL & Strong === Close[26] is above the cloud when cross happens
Def is_SpanAB_Cross = if crosses("Span A","Span B", CrossingDirection.ABOVE) then 1 else 0;
def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud

Plot SpanAB_StrongBull = if is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB &&  want_Strong && want_Bull  then "Span A" else Double.Nan;
SpanAB_StrongBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_StrongBull.SetLineWeight(5);
SpanAB_StrongBull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB &&  want_Strong && want_Bull,"Span A","Strong\nBullish", Color.WHITE, yes);
def Cond_VertLine = if is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB &&  want_Strong && want_Bull then barnumber() - 26 else Double.Nan;
#AddVerticalLine(boolean visible, Any text, CustomColor color, int stroke);
AddVerticalLine(SpanAB_StrongBull[-26],"price  RE  the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

###=== BULL & NEUTRAL ===
# This signal happens infrequently
def IsInCloud_26 = if (("Span A"[26] > "Span B"[26] && close[26] < "Span A"[26] && close[26] > "Span B"[26]) or ("Span B"[26] > "Span A"[26] && close[26] > "Span A"[26] && close[26] < "Span B"[26]),1,0);#Proven InCloud code shifte 26 bars back for the SpanAB signals only

def isSpanAB_NeutralCross = is_SpanAB_Cross && IsInCloud_26;
Plot SpanAB_NeutralBull = if is_SpanAB_Cross && IsInCloud_26 && is_SpanAB && want_neutral && want_Bull then "Span A" else Double.Nan;
SpanAB_NeutralBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_NeutralBull.SetLineWeight(5);
SpanAB_NeutralBull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_SpanAB_Cross && IsInCloud_26 && is_SpanAB && want_neutral && want_Bull ,"Span A","neutral\nBullish", Color.WHITE, yes);
AddVerticalLine(SpanAB_NeutralBull[-26],"price  RE  the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BULL & WEAK ===
def isSpanAB_BelowCloud_26 = close[26] < "Span A"[26] && close[26] < "Span B"[26];
Plot SpanAB_WeakBull = if is_SpanAB_Cross && is_SpanAB && isSpanAB_BelowCloud_26 && want_weak && want_Bull then "Span A" else Double.Nan;
SpanAB_WeakBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_WeakBull.SetLineWeight(5);
SpanAB_WeakBull.SetDefaultColor(GlobalColor("Bullweak"));

AddChartBubble(ShowBubbles &&  is_SpanAB_Cross && is_SpanAB && isSpanAB_BelowCloud_26 && want_weak && want_Bull,"Span A","weak\nBullish", Color.WHITE, yes);
#AddVerticalLine(boolean visible, Any text, CustomColor color, int stroke);
AddVerticalLine(SpanAB_WeakBull[-26],"price  RE  the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

##===  SpanAS Bearish SIGNALS ===
###########################
#def is_SpanAB = if Type_Signal == Type_Signal."SpanA/B Cross" then 1 else 0;
#A Bearish signal is when Span A crosses below Span B (or Span B crosses above Span A)
def SpanAS_Bearish_Cross = if crosses("Span A","Span B", CrossingDirection.BELOW) then 1 else 0;

###=== SpanAS BEAR & Strong ===
######################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_StrongBear = if SpanAS_Bearish_Cross && isSpanAB_BelowCloud_26 && is_SpanAB &&  want_Strong && want_Bear  then "Span B" else Double.Nan;
SpanAB_StrongBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_StrongBear.SetLineWeight(5);
SpanAB_StrongBear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && isSpanAB_BelowCloud_26 && is_SpanAB &&  want_Strong && want_Bear,"Span B","Strong\nBearish", Color.WHITE, no);
AddVerticalLine(SpanAB_StrongBear[-26],"price  RE  the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BEAR & NEUTRAL ===
#########################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_NeutralBear = if SpanAS_Bearish_Cross && IsInCloud_26 && is_SpanAB &&  want_Neutral && want_Bear then "Span B" else Double.Nan;
SpanAB_NeutralBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_NeutralBear.SetLineWeight(5);
SpanAB_NeutralBear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && IsInCloud_26 && is_SpanAB &&  want_Neutral && want_Bear ,"Span B","Neutral\nBearish", Color.WHITE, no);

AddVerticalLine(SpanAB_NeutralBear[-26],"price  RE  the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BEAR & WEAK ===
#########################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_WeakBear = if SpanAS_Bearish_Cross && isSpanAB_AboveCloud_26 && is_SpanAB &&  want_Weak && want_Bear  then "Span B" else Double.Nan;
SpanAB_WeakBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_WeakBear.SetLineWeight(5);
SpanAB_WeakBear.SetDefaultColor(GlobalColor("BearWeak"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && isSpanAB_AboveCloud_26 && is_SpanAB &&  want_Weak && want_Bear,"Span B","Weak\nBearish", Color.WHITE, no);
AddVerticalLine(SpanAB_WeakBear[-26],"price  RE  the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###########################################
#==== CHIKOU CROSS(CC) SIGNALS  ====  ##
#chikou cross is essentially the "chikou confirmation" that savvy Ichimoku traders utilize to confirm chart sentiment before entering any trade. This confirmation comes in the form of the chikou crossing through the price curve in the direction of the proposed trade. If it crosses through the price curve from the bottom up, then it is a Bullish signal. If it crosses from the top down, then it is considered a Bearish signal.
############################################
def is_ChikouCross = if Type_Signal == Type_Signal."Chikou Cross" then 1 else 0;
#=== ===CHIKOU CROSS Bullish SIGNALS ===

###########################
#Bullish = Chikou crsses above close.Strong when close is above the cloud.
def ChikouCross_Bull = if Crosses(Chikou,close, CrossingDirection.ABOVE) then 1 else 0;

####=== CHIKOU CROSS BULL & Strong ===
plot CC_Strong_Bull = If (is_ChikouCross && ChikouCross_Bull && IsAboveCloud &&  want_Strong && want_Bull, Chikou, Double.NaN);
CC_Strong_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Strong_Bull.SetLineWeight(5);
CC_Strong_Bull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsAboveCloud &&  want_Strong && want_Bull, Chikou, "Strong\nBullish",  Color.WHITE, yes);

###=== CHIKOU CROSS BULL & NEUTRAL ===
plot CC_Neutral_Bull = If (is_ChikouCross && ChikouCross_Bull && IsInCloud &&  want_Neutral && want_Bull, Chikou,
Double.NaN);
CC_Neutral_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Neutral_Bull.SetLineWeight(5);
CC_Neutral_Bull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsInCloud &&  want_Neutral && want_Bull, Chikou, "neutral\nBullish",  Color.WHITE, yes);

###=== CHIKOU CROSS BULL & WEAK ===
plot CC_Weak_Bull = If (is_ChikouCross && ChikouCross_Bull && IsBelowCloud &&  want_Weak && want_Bull, Chikou, Double.NaN);
CC_Weak_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Weak_Bull.SetLineWeight(5);
CC_Weak_Bull.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsBelowCloud &&  want_Weak && want_Bull, Chikou, "weak\nBullish",  Color.WHITE, yes);

##===  CHIKOU CROSS Bearish SIGNALS ===
###########################
#         === Chikou Cross Bear & Strong ====
#Bearish = Chokou crosses below the close
#===      === CHIKOU CROSS BEAR & Strong ===
def ChikouCross_Bear = if Crosses(Chikou,close, CrossingDirection.BELOW) then 1 else 0;
plot CC_Strong_Bear = If (is_ChikouCross && ChikouCross_Bear && IsBelowCloud &&  want_Strong && want_BEAR, Chikou, Double.NaN);
CC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Strong_Bear.SetLineWeight(5);
CC_Strong_Bear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsBelowCloud &&  want_Strong && want_BEAR, Chikou, "Strong\nBearish",  Color.WHITE, no);

#===      === CHIKOU CROSS BEAR & NEUTRAL ===
plot CC_Neutral_Bear = If (is_ChikouCross && ChikouCross_Bear && IsInCloud &&  want_Neutral && want_BEAR, Chikou, Double.NaN);
CC_Neutral_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Neutral_Bear.SetLineWeight(5);
CC_Neutral_Bear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsInCloud &&  want_Neutral && want_BEAR, Chikou, "Neutral\nBearish",  Color.WHITE, no);

#===      === CHIKOU CROSS BEAR & WEAK ===
plot CC_Weak_Bear = If (is_ChikouCross && ChikouCross_Bear && IsAboveCloud &&  want_Weak && want_BEAR, Chikou, Double.NaN);
CC_Weak_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Weak_Bear.SetLineWeight(5);
CC_Weak_Bear.SetDefaultColor(GlobalColor("BearWeak"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsAboveCloud &&  want_Weak && want_BEAR, Chikou, "Weak\nBearish",  Color.WHITE, no);

#====== LABELS ========
AddLabel(ShowColorLabels, "Strong Bullish", CreateColor(82, 242, 234));#aqua
AddLabel(ShowColorLabels, "Neutral Bullish", CreateColor(155, 215, 213));#medium aqua
AddLabel(ShowColorLabels, "Weak Bullish", CreateColor(36, 179, 172));#dark aqua
AddLabel(ShowColorLabels, "Strong Bearish", CreateColor(255, 0, 255));#light = magenta
AddLabel(ShowColorLabels, "Neutral Bearish", CreateColor(221, 160, 221));#medium plum
AddLabel(ShowColorLabels, "Weak Bearish", CreateColor(186, 85, 211));#med orchid orchid

#==== Coding of labels for input-type of signals selected =======
AddLabel(yes, "The type of signal selected is " + (if Type_Signal == Type_Signal."T/K Cross" then "'Tenkan/Kijun Cross'"
  else if Type_Signal == Type_Signal."Kijun Cross" then "'Kijun Cross'"
  else if Type_Signal == Type_Signal."Cloud BreakOut" then "'Cloud BreakOut'"
  else if Type_Signal == Type_Signal."SpanA/B Cross" then "'SpanA/B Cross'"
  else if Type_Signal == Type_Signal."Chikou Cross" then "'Chikou Cross'"
  else ""), Color.WHITE);
AddLabel(yes, "The signal strength selected is " + (if Signal_strength == Signal_strength."Strong" then "'Strong'"
  else if Signal_strength == Signal_strength."Neutral" then "'Neutral'"
  else if Signal_strength == Signal_strength."Weak" then "'Weak'"
  else if Signal_strength == Signal_strength."All" then "'All'"
  else ""), Color.WHITE);
AddLabel(yes, "The Bullish/Bearish sentiment selected is " + (if Bullish_Bearish == Bullish_Bearish."Bullish" then "'Bullish'"
  else if Bullish_Bearish == Bullish_Bearish."Bearish" then "'Bearish'"
  else if Bullish_Bearish == Bullish_Bearish."Both" then "'Both'"
  else ""), Color.WHITE);
#=== of code ###
 
Last edited by a moderator:

BenTen

Administrative
Staff
VIP
The script is incomplete, as indicated by the developer. Right above line 221, you can see the following message "THE CODE BELLOW MAY NEED FIXING KIP"
 

henry1224

Member
VIP
Here is the corrected code

Code:
##############
##Hint:This Ichmoku study has many signals. Some are more important/controlling than others. This study allows you to select the type of signal you are interested in, the strength level of those signals and the Bullish or Bearish sentiment.The appropriate arrows will be plotted with optional bubbles to identify the signal strength and bull/bear.
# TOS title = 'Ichi_Signals' by StanL version 1.0
#USAGE NOTES: !.All Bullish signals are UP arrows of cyan coloring. All Bearish signals are DOWN arrows of magenta coloring.
#2.Bubbles may be toggled OFF to avoid chart clutter. All bubbles are colored white for readability.
#3.Selectable inputs for arrow plotting are:1. Each of the 5 Ichimoku parameters(lines); 2.Signal strengths of Strong, neutral, weak or All;3.Bullish, Bearish or All.
# The main Ichimoku signals to monitor, in order of importance, are:
# 1. Price vs Cloud (the 'big picture')
# 2. Price vs Tenkan/Kijun
# 3. Momentum
# 4. Future Cloud
#These signals are not 'stand alone' for decision making and must be evaluated using other related ichimoku data as well as other external studies and indicators.
#A free detailed reference, 'Ichmoku E-Book', is available at [URL]https://www.ichimokutrade.com/c/videos/categories/ichimoku-videos/[/URL] as well as a tutorial at [URL]http://www.kumotrader.com/ichimoku_wiki/index.php?title=Ichimoku_components[/URL]
#The E-Book has details for developing buy/sell strategies using the Ichimoku signals.

input ShowBubbles = yes;#Hint ShowBubbles:Toggles bubbles ON/OFF
input ShowColorLabels = Yes;#hint ShowColorLabels:Toggles the color coding labels ON/OFF
input tenkan_period = 9;#Hint tenkan_period: The number of bars used to calculate the Tenkan cyan plot. Default is 9. Change of this value is not recommended.
input kijun_period = 26;#Hint kijun_period: The number of bars used to calculate the Kijun pink plot. Default is 26. Change of this value is not recommended.
input Type_Signal = {default "T/K Cross", "Kijun Cross", "Cloud BreakOut", "SpanA/B Cross", "Chikou Cross"};#Hint Type_Signal:Select the type of signal to show. All is not a choice because there would be too many signals to show. Each choice could have up to 6 signals i.e. Bullish/Bearish, Strong, Neutral & Weak signals.
input Signal_strength = {default Strong, Neutral, Weak, All};#hint Signal_strength:Show only signals having the strength selected
input Bullish_Bearish = {default Bullish, Bearish, Both};#hint Bullish_Bearish:Select the orientation desired

plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot "Span A" = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot "Span B" = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];
Tenkan.SetDefaultColor(GetColor(1));
#Kijun.SetDefaultColor(GetColor(2));
"Span A".SetDefaultColor(GetColor(3));
"Span B".SetDefaultColor(GetColor(4));
Chikou.SetDefaultColor(GetColor(5));
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud("Span A", "Span B", GlobalColor("Bullish"), GlobalColor("Bearish"));

#=== Define global colors ===
# aqua is Bullish & ARROW_UP
DefineGlobalColor("BullStrong", CreateColor(82, 242, 234));#light aqua
DefineGlobalColor("BullNeutral", CreateColor(155, 215, 213));#medium aqua
DefineGlobalColor("BullWeak", CreateColor(36, 179, 172));#dark aqua
#magenta tint is Bearish & ARROW_DOWN
DefineGlobalColor("BearStrong", CreateColor(255, 0, 255));#light = magenta
DefineGlobalColor("BearNeutral", CreateColor(221, 160, 221));#medium plum
DefineGlobalColor("BearWeak", CreateColor(186, 85, 211));#med orchid
#DefineGlobalColor("Global1", CreateColor(128, 0, 128));
#?.SetDefaultColor(GlobalColor("?"));

#=== BASIC CONDITIONS ====
def IsAboveCloud = if close > Ichimoku()."Span A" && close > Ichimoku()."Span B" then 1 else 0; # close is above the cloud
def IsBelowCloud = if close < Ichimoku()."Span A" && close < Ichimoku()."Span B" then 1 else 0; # close is below the cloud
def IsInCloud = if (("Span A" > "Span B" && close[0] < "Span A" && close[0] > "Span B") or ("Span B" > "Span A" &&
close[0] > "Span A" && close[0] < "Span B"),1,0);#This code has been analyzed & proven accurate
#def IsInCloud = If close > Min(Ichimoku()."Span A",Ichimoku()."Span B") && close < Max(Ichimoku()."SpanA",Ichimoku()."Span B") then 1 else 0;# Close is in the cloud
#def IsInCloud = if close > Min("Span A", "Span B") && close < Max("Span A", "Span B") then 1 else 0;# Close is in the cloud
def want_Strong = if Signal_strength == Signal_strength."Strong" or Signal_strength == Signal_strength."All" then 1 else 0;
def want_Neutral = if Signal_strength == Signal_strength."Neutral" or Signal_strength == Signal_strength."All" then 1 else 0;
def want_Weak = if Signal_strength == Signal_strength."Weak" or Signal_strength == Signal_strength."All" then 1 else 0;
def want_Bull = if Bullish_Bearish == Bullish_Bearish."Bullish" or Bullish_Bearish == Bullish_Bearish."Both" then 1 else 0;
def want_Bear = if Bullish_Bearish == Bullish_Bearish."Bearish" or Bullish_Bearish == Bullish_Bearish."Both" then 1 else 0
;
###############################################
#==== TENKAN/KIJUN (T/K) CROSS SIGNALS ==== #
#The tenkan/kijun cross is one of the most traditional trading strategies within the Ichimoku system.

###############################################
def Is_TKC = if Type_Signal == Type_Signal."T/K Cross" then 1 else 0;
#=== === Bullish SIGNALS == T crosses above the K ====
#===================================================
#=== === Strong T/K Bullish cross happens while ABOVE the cloud ===
def cond_STK = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsAboveCloud;

plot STK_Cross = If (cond_STK && Is_TKC && want_Strong && want_Bull , Tenkan, Double.NaN);
STK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
STK_Cross.SetLineWeight(5);
STK_Cross.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && cond_STK && Is_TKC && want_Strong && want_Bull , Tenkan, "Strong\nBullish", Color.WHITE, yes);

###=== NEUTRAL T/K cross(NTKC)happens while IN the cloud ===
def cond_NTKC = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsInCloud;

plot NTK_Cross = If(cond_NTKC && Is_TKC && want_Neutral && want_Bull , Tenkan, Double.NaN);
NTK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
NTK_Cross.SetLineWeight(5);
NTK_Cross.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && cond_NTKC && Is_TKC && want_Neutral && want_Bull , Tenkan, "Neutral\nBullish", Color.WHITE, yes);

###=== WEAK cross T/K(WTKC) happens while BELOW the cloud ===
def cond_WTKC = Crosses(Tenkan, Kijun, CrossingDirection.ABOVE) && IsBelowCloud;

plot WTK_Cross = If(cond_NTKC && Is_TKC && want_Bull && want_Weak, Tenkan, Double.NaN);
WTK_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
WTK_Cross.SetLineWeight(5);
WTK_Cross.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && cond_NTKC && Is_TKC && want_Bull && want_Weak, Tenkan, "Weak\nBullish", Color.WHITE, yes);

##=== Bearish SIGNALS == T crosses below the K (K/T)====
##############################################
#=== === Strong K/T Bearish cross happens while BELOW the cloud===
def cond_SKT_Cross = Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsBelowCloud;

plot SKT_Cross = If(cond_SKT_Cross && Is_TKC && want_Strong && want_Bear, Tenkan, Double.NaN);
SKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SKT_Cross.SetLineWeight(5);
SKT_Cross.SetDefaultColor(CreateColor(255, 0, 255));

AddChartBubble(ShowBubbles && cond_SKT_Cross && Is_TKC && want_Strong && want_Bear , Tenkan, "Strong\nBearish", Color.WHITE, yes);

###=== NEUTRAL cross K/T happens while IN the cloud ===
def cond_NKT_Cross = Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsInCloud;

plot NKT_Cross = If(cond_NKT_Cross && Is_TKC && want_Neutral && want_Bear, Tenkan, Double.NaN);
NKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
NKT_Cross.SetLineWeight(5);
NKT_Cross.SetDefaultColor(CreateColor(221, 160, 221));

AddChartBubble(ShowBubbles && cond_NKT_Cross && Is_TKC && want_Neutral && want_Bear , Tenkan, "Neutral\nBearish", Color.WHITE, yes);

#=== === WEAK cross K/T happens while ABOVE the cloud ===
def Cond_WKT_Cross = Crosses(Tenkan, Kijun, CrossingDirection.BELOW) && IsAboveCloud;

plot WKT_Cross = If (Cond_WKT_Cross && Is_TKC && want_Weak && want_Bear, Tenkan, Double.NaN);
WKT_Cross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
WKT_Cross.SetLineWeight(5);
WKT_Cross.SetDefaultColor(CreateColor(186, 85, 211));

AddChartBubble(ShowBubbles && Cond_WKT_Cross && Is_TKC && want_Weak && want_Bear , Tenkan,"Weak\nBearish", Color.WHITE, no);

#####################################
#==== KIJUN CROSS SIGNALS ==== ##
#The kijun cross is one of the most powerful and reliable trading strategies within the Ichimoku system. It can be used on nearly all time frames with excellent results, though it will be somewhat less reliable on the lower, daytrading time frames due to the increased volatility on those time frames.
#####################################
def is_KC = if Type_Signal == Type_Signal."Kijun Cross" then 1 else 0;
#=== === Bullish SIGNALS when close crosses above the Kijun
#######################################
#=== === BULL & Strong ===
def is_KC_bull_Strong = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsAboveCloud;

plot KC_Strong_Bull = If (is_KC_bull_Strong && is_KC && want_Strong && want_Bull, Kijun, Double.NaN);
KC_Strong_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_Strong_Bull.SetLineWeight(5);
KC_Strong_Bull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_KC_bull_Strong && is_KC && want_Strong && want_Bull , Kijun, "Strong\nBullish",Color.WHITE, yes);

#=== === BULL & NEUTRAL ===
def is_KC_bull_neutral = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsInCloud;

plot KC_neutral_Bull = If (is_KC_bull_neutral && is_KC && want_Neutral && want_Bull, Kijun, Double.NaN);
KC_neutral_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_neutral_Bull.SetLineWeight(5);
KC_neutral_Bull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_KC_bull_neutral && is_KC && want_Neutral && want_Bull , Kijun, "Neutral\nBullish", Color.WHITE, yes);

#=== === BULL & WEAK ===
def is_KC_bull_weak = Crosses(close, Kijun, CrossingDirection.ABOVE) && IsBelowCloud;

plot KC_weak_Bull = If (is_KC_bull_weak && is_KC && want_Weak && want_Bull, Kijun, Double.NaN);
KC_weak_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
KC_weak_Bull.SetLineWeight(5);
KC_weak_Bull.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && is_KC_bull_weak && is_KC && want_Weak && want_Bull , Kijun, "weak\nBullish",Color.WHITE, yes);

#=== === Bearish SIGNALS when close crosses below the Kijun
####################################
#=== === BEAR & Strong ===
def is_KC_bear_Strong = Crosses(close, Kijun, CrossingDirection.BELOW) && IsBelowCloud;

plot KC_Strong_Bear = If (is_KC_bear_Strong && is_KC && want_Strong && want_Bear, Kijun, Double.NaN);
KC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_Strong_Bear.SetLineWeight(5);
KC_Strong_Bear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && is_KC_bear_Strong && is_KC && want_Strong && want_Bear , Kijun,"Strong\nBearish", Color.WHITE, yes);

#=== === BEAR & NEUTRAL ===
def is_KC_bear_neutral = Crosses(close, Kijun, CrossingDirection.BELOW) && IsInCloud;

plot KC_neutral_Bear = If (is_KC_bear_neutral && is_KC && want_Neutral && want_Bear, Kijun, Double.NaN);
KC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_Strong_Bear.SetLineWeight(5);
KC_Strong_Bear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && is_KC_bear_neutral && is_KC && want_Neutral && want_Bear, Kijun, "neutral\nBearish", Color.WHITE, yes);

#=== === BEAR & WEAK ===
def is_KC_bear_weak = Crosses(close, Kijun, CrossingDirection.BELOW) && IsAboveCloud;

plot KC_weak_Bear = If (is_KC_bear_weak && is_KC && want_Weak && want_Bear, Kijun, Double.NaN);
KC_weak_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
KC_weak_Bear.SetLineWeight(5);
KC_weak_Bear.SetDefaultColor(GlobalColor("Bearweak"));

AddChartBubble(ShowBubbles && is_KC_bear_weak && is_KC && want_Weak && want_Bear, Kijun, "weak\nBearish", Color.WHITE, yes);

#################################
#==== CLOUD BREAKOUT SIGNALS ==== ##
#CLOUD BREAKOUT trading is a trading strategy that can be used on multiple time frames, though it is most widely used on the higher time frames (e.g.: Daily, Weekly, Monthly). CLOUD breakout trading is the purest form of trend trading offered by the Ichimoku charting system, as it looks solely to the CLOUD and price's(close) relationship to it for its signals. It is "big picture" trading that focuses only on whether price is trading above or below the prevailing CLOUD. . In a nutshell, the signal to go long in CLOUD BREAKOUT trading is when price closes above the prevailing CLOUD and, likewise, the signal to go short is when price closes below the prevailing CLOUD.

#############################
def is_CBO = if Type_Signal == Type_Signal."Cloud BreakOut" then 1 else 0;
#=== === Bullish SIGNALS ===
###########################
#A Bullish signal is present when the close moves above the cloud. Caution is needed if close is rising above a flat-top- cloud (a persistent resistance). The position of the close related to the cloud is the most controlling aspect of signal evaluation.....it is the 'Big Picture'.
def SpanA_OnTop = if ("Span A" > "Span B",1,0);
def isCBO_bull_aboveA = if "Span A" > "Span B" && crosses(close,"Span A",CrossingDirection.ABOVE) then 1 else 0;
def isCBO_bull_aboveB = if "Span B" > "Span A" && crosses(close,"Span B",CrossingDirection.ABOVE) then 1 else 0;

plot CBO_Bull_Strong = if (isCBO_bull_aboveA or isCBO_bull_aboveB) && is_CBO && want_Strong && want_Bull then close else Double.Nan;
CBO_Bull_Strong.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CBO_Bull_Strong.SetLineWeight(5);
CBO_Bull_Strong.SetDefaultColor(GlobalColor("BullStrong"));

#######THE CODE BELLOW MAY NEED FIXING KIP #########
def isCBO_bull_cross = isCBO_bull_aboveA ==1 or isCBO_bull_aboveB ==1;
def is_FlatTop = If (isCBO_bull_cross && SpanA_OnTop && Sum("Span A" > .90 * "Span A"[1], 8) >= 5) then 1 else if (isCBO_bull_cross && !SpanA_OnTop && sum("Span B" > .95 * "Span B"[1],8) >= 5) then 1 else 0;
def SpanA_FlatTop = If (isCBO_bull_cross && SpanA_OnTop && Sum("Span A" == "Span A"[1], 8) >= 5, 1, 0);
def SpanB_FlatTop = If (isCBO_bull_cross && !SpanA_OnTop && Sum("Span B" == "Span B"[1], 8) >= 5, 1, 0);
AddChartBubble(ShowBubbles && (isCBO_bull_aboveA or isCBO_bull_aboveB) && is_CBO && want_Strong && want_Bull,close,"Strong\nBullish", Color.WHITE, yes);

#=== === Bearish SIGNALS ===
###########################
#=== === BEAR & Strong ===
def isCBO_Strong_bearA = if "Span A" < "Span B" && crosses(close,"Span A",CrossingDirection.BELOW) then 1 else 0;
def isCBO_Strong_bearB = if "Span B" < "Span A" && crosses(close,"Span B",CrossingDirection.BELOW) then 1 else 0;
plot CBO_Bear_Strong = if (isCBO_Strong_bearA or isCBO_Strong_bearB) && is_CBO && want_Strong && want_Bear then close else Double.Nan;
CBO_Bear_Strong.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CBO_Bear_Strong.SetLineWeight(5);
CBO_Bear_Strong.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && (isCBO_Strong_bearA or isCBO_Strong_bearB) && is_CBO && want_Strong && want_Bear,close,"Strong\nBearish", Color.WHITE, yes);
##################################################
#==== 'SPAN A' & 'SPAN B' CROSS SIGNALS (SpanAD)==== ###
#The 'Span A' and 'Span B' cross is one of the lesser known trading strategies within the Ichimoku system. This is mostly due to the fact that the 'Span A' cross tends to be more commonly used as an additional confirmation with other trading strategies rather than being used as a standalone trading strategy in its own right. it is best employed on the longer time frames of the Daily chart and above. Keep in mind with the Span crossings is that the "cross" signal will take place 26 periods ahead of the price action as the CLOUD is time-shifted 26 periods into the future.

##################################################
def is_SpanAB = if Type_Signal == Type_Signal."SpanA/B Cross" then 1 else 0;

#=== === Bullish SIGNALS ===
###########################
#=== === SpanAB BULL & Strong === Close[26] is above the cloud when cross happens
Def is_SpanAB_Cross = if crosses("Span A","Span B", CrossingDirection.ABOVE) then 1 else 0;
def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud

Plot SpanAB_StrongBull = if is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB && want_Strong && want_Bull then "Span A" else Double.Nan;
SpanAB_StrongBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_StrongBull.SetLineWeight(5);
SpanAB_StrongBull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB && want_Strong && want_Bull,"Span A","Strong\nBullish", Color.WHITE, yes);
def Cond_VertLine = if is_SpanAB_Cross && isSpanAB_AboveCloud_26 && is_SpanAB && want_Strong && want_Bull then barnumber() - 26 else Double.Nan;
#AddVerticalLine(boolean visible, Any text, CustomColor color, int stroke);
AddVerticalLine(SpanAB_StrongBull[-26],"price RE the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

###=== BULL & NEUTRAL ===
# This signal happens infrequently
def IsInCloud_26 = if (("Span A"[26] > "Span B"[26] && close[26] < "Span A"[26] && close[26] > "Span B"[26]) or ("Span B"[26] > "Span A"[26] && close[26] > "Span A"[26] && close[26] < "Span B"[26]),1,0);#Proven InCloud code shifte 26 bars back for the SpanAB signals only

def isSpanAB_NeutralCross = is_SpanAB_Cross && IsInCloud_26;
Plot SpanAB_NeutralBull = if is_SpanAB_Cross && IsInCloud_26 && is_SpanAB && want_neutral && want_Bull then "Span A" else Double.Nan;
SpanAB_NeutralBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_NeutralBull.SetLineWeight(5);
SpanAB_NeutralBull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_SpanAB_Cross && IsInCloud_26 && is_SpanAB && want_neutral && want_Bull ,"Span A","neutral\nBullish", Color.WHITE, yes);
AddVerticalLine(SpanAB_NeutralBull[-26],"price RE the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BULL & WEAK ===
def isSpanAB_BelowCloud_26 = close[26] < "Span A"[26] && close[26] < "Span B"[26];
Plot SpanAB_WeakBull = if is_SpanAB_Cross && is_SpanAB && isSpanAB_BelowCloud_26 && want_weak && want_Bull then "Span A" else Double.Nan;
SpanAB_WeakBull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SpanAB_WeakBull.SetLineWeight(5);
SpanAB_WeakBull.SetDefaultColor(GlobalColor("Bullweak"));

AddChartBubble(ShowBubbles && is_SpanAB_Cross && is_SpanAB && isSpanAB_BelowCloud_26 && want_weak && want_Bull,"Span A","weak\nBullish", Color.WHITE, yes);
#AddVerticalLine(boolean visible, Any text, CustomColor color, int stroke);
AddVerticalLine(SpanAB_WeakBull[-26],"price RE the following SpanA Cross",color.cyan,Curve.SHORT_DASH);

##=== SpanAS Bearish SIGNALS ===
###########################
#def is_SpanAB = if Type_Signal == Type_Signal."SpanA/B Cross" then 1 else 0;
#A Bearish signal is when Span A crosses below Span B (or Span B crosses above Span A)
def SpanAS_Bearish_Cross = if crosses("Span A","Span B", CrossingDirection.BELOW) then 1 else 0;

###=== SpanAS BEAR & Strong ===
######################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_StrongBear = if SpanAS_Bearish_Cross && isSpanAB_BelowCloud_26 && is_SpanAB && want_Strong && want_Bear then "Span B" else Double.Nan;
SpanAB_StrongBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_StrongBear.SetLineWeight(5);
SpanAB_StrongBear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && isSpanAB_BelowCloud_26 && is_SpanAB && want_Strong && want_Bear,"Span B","Strong\nBearish", Color.WHITE, no);
AddVerticalLine(SpanAB_StrongBear[-26],"price RE the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BEAR & NEUTRAL ===
#########################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_NeutralBear = if SpanAS_Bearish_Cross && IsInCloud_26 && is_SpanAB && want_Neutral && want_Bear then "Span B" else Double.Nan;
SpanAB_NeutralBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_NeutralBear.SetLineWeight(5);
SpanAB_NeutralBear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && IsInCloud_26 && is_SpanAB && want_Neutral && want_Bear ,"Span B","Neutral\nBearish", Color.WHITE, no);

AddVerticalLine(SpanAB_NeutralBear[-26],"price RE the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###=== SpanAS BEAR & WEAK ===
#########################################
#def isSpanAB_AboveCloud_26 = if close[26] > "Span A"[26] && close[26] > "Span B"[26]then 1 else 0;#close[26] is above the cloud
Plot SpanAB_WeakBear = if SpanAS_Bearish_Cross && isSpanAB_AboveCloud_26 && is_SpanAB && want_Weak && want_Bear then "Span B" else Double.Nan;
SpanAB_WeakBear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SpanAB_WeakBear.SetLineWeight(5);
SpanAB_WeakBear.SetDefaultColor(GlobalColor("BearWeak"));

AddChartBubble(ShowBubbles && SpanAS_Bearish_Cross && isSpanAB_AboveCloud_26 && is_SpanAB && want_Weak && want_Bear,"Span B","Weak\nBearish", Color.WHITE, no);
AddVerticalLine(SpanAB_WeakBear[-26],"price RE the previous Span B/A Cross",color.cyan,Curve.SHORT_DASH);

###########################################
#==== CHIKOU CROSS(CC) SIGNALS ==== ##
#chikou cross is essentially the "chikou confirmation" that savvy Ichimoku traders utilize to confirm chart sentiment before entering any trade. This confirmation comes in the form of the chikou crossing through the price curve in the direction of the proposed trade. If it crosses through the price curve from the bottom up, then it is a Bullish signal. If it crosses from the top down, then it is considered a Bearish signal.
############################################
def is_ChikouCross = if Type_Signal == Type_Signal."Chikou Cross" then 1 else 0;
#=== ===CHIKOU CROSS Bullish SIGNALS ===

###########################
#Bullish = Chikou crsses above close.Strong when close is above the cloud.
def ChikouCross_Bull = if Crosses(Chikou,close, CrossingDirection.ABOVE) then 1 else 0;

####=== CHIKOU CROSS BULL & Strong ===
plot CC_Strong_Bull = If (is_ChikouCross && ChikouCross_Bull && IsAboveCloud && want_Strong && want_Bull, Chikou, Double.NaN);
CC_Strong_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Strong_Bull.SetLineWeight(5);
CC_Strong_Bull.SetDefaultColor(GlobalColor("BullStrong"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsAboveCloud && want_Strong && want_Bull, Chikou, "Strong\nBullish", Color.WHITE, yes);

###=== CHIKOU CROSS BULL & NEUTRAL ===
plot CC_Neutral_Bull = If (is_ChikouCross && ChikouCross_Bull && IsInCloud && want_Neutral && want_Bull, Chikou,
Double.NaN);
CC_Neutral_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Neutral_Bull.SetLineWeight(5);
CC_Neutral_Bull.SetDefaultColor(GlobalColor("BullNeutral"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsInCloud && want_Neutral && want_Bull, Chikou, "neutral\nBullish", Color.WHITE, yes);

###=== CHIKOU CROSS BULL & WEAK ===
plot CC_Weak_Bull = If (is_ChikouCross && ChikouCross_Bull && IsBelowCloud && want_Weak && want_Bull, Chikou, Double.NaN);
CC_Weak_Bull.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
CC_Weak_Bull.SetLineWeight(5);
CC_Weak_Bull.SetDefaultColor(GlobalColor("BullWeak"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bull && IsBelowCloud && want_Weak && want_Bull, Chikou, "weak\nBullish", Color.WHITE, yes);

##=== CHIKOU CROSS Bearish SIGNALS ===
###########################
# === Chikou Cross Bear & Strong ====
#Bearish = Chokou crosses below the close
#=== === CHIKOU CROSS BEAR & Strong ===
def ChikouCross_Bear = if Crosses(Chikou,close, CrossingDirection.BELOW) then 1 else 0;
plot CC_Strong_Bear = If (is_ChikouCross && ChikouCross_Bear && IsBelowCloud && want_Strong && want_BEAR, Chikou, Double.NaN);
CC_Strong_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Strong_Bear.SetLineWeight(5);
CC_Strong_Bear.SetDefaultColor(GlobalColor("BearStrong"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsBelowCloud && want_Strong && want_BEAR, Chikou, "Strong\nBearish", Color.WHITE, no);

#=== === CHIKOU CROSS BEAR & NEUTRAL ===
plot CC_Neutral_Bear = If (is_ChikouCross && ChikouCross_Bear && IsInCloud && want_Neutral && want_BEAR, Chikou, Double.NaN);
CC_Neutral_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Neutral_Bear.SetLineWeight(5);
CC_Neutral_Bear.SetDefaultColor(GlobalColor("BearNeutral"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsInCloud && want_Neutral && want_BEAR, Chikou, "Neutral\nBearish", Color.WHITE, no);

#=== === CHIKOU CROSS BEAR & WEAK ===
plot CC_Weak_Bear = If (is_ChikouCross && ChikouCross_Bear && IsAboveCloud && want_Weak && want_BEAR, Chikou, Double.NaN);
CC_Weak_Bear.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
CC_Weak_Bear.SetLineWeight(5);
CC_Weak_Bear.SetDefaultColor(GlobalColor("BearWeak"));

AddChartBubble(ShowBubbles && is_ChikouCross && ChikouCross_Bear && IsAboveCloud && want_Weak && want_BEAR, Chikou, "Weak\nBearish", Color.WHITE, no);

#====== LABELS ========
AddLabel(ShowColorLabels, "Strong Bullish", CreateColor(82, 242, 234));#aqua
AddLabel(ShowColorLabels, "Neutral Bullish", CreateColor(155, 215, 213));#medium aqua
AddLabel(ShowColorLabels, "Weak Bullish", CreateColor(36, 179, 172));#dark aqua
AddLabel(ShowColorLabels, "Strong Bearish", CreateColor(255, 0, 255));#light = magenta
AddLabel(ShowColorLabels, "Neutral Bearish", CreateColor(221, 160, 221));#medium plum
AddLabel(ShowColorLabels, "Weak Bearish", CreateColor(186, 85, 211));#med orchid orchid

#==== Coding of labels for input-type of signals selected =======
AddLabel(yes, "The type of signal selected is " + (if Type_Signal == Type_Signal."T/K Cross" then "'Tenkan/Kijun Cross'"
else if Type_Signal == Type_Signal."Kijun Cross" then "'Kijun Cross'"
else if Type_Signal == Type_Signal."Cloud BreakOut" then "'Cloud BreakOut'"
else if Type_Signal == Type_Signal."SpanA/B Cross" then "'SpanA/B Cross'"
else if Type_Signal == Type_Signal."Chikou Cross" then "'Chikou Cross'"
else ""), Color.WHITE);
AddLabel(yes, "The signal strength selected is " + (if Signal_strength == Signal_strength."Strong" then "'Strong'"
else if Signal_strength == Signal_strength."Neutral" then "'Neutral'"
else if Signal_strength == Signal_strength."Weak" then "'Weak'"
else if Signal_strength == Signal_strength."All" then "'All'"
else ""), Color.WHITE);
AddLabel(yes, "The Bullish/Bearish sentiment selected is " + (if Bullish_Bearish == Bullish_Bearish."Bullish" then "'Bullish'"
else if Bullish_Bearish == Bullish_Bearish."Bearish" then "'Bearish'"
else if Bullish_Bearish == Bullish_Bearish."Both" then "'Both'"
else ""), Color.WHITE);
#=== of code ###
 

kmg526

Member
VIP
I am not sure what needs to be fixed..but I just watch 5 stocks with strong signals go up...so...with my other indicators, it works pretty well along with the Ichimoku Trade Confirmation that Ben made!!
 

Similar threads

Top