gp66
New member
I'm new to ThinkScript and can't seem to figure out how to draw only one arrow on a Kumo breakout.
I tried the code from this post but it misses too many breakouts.
https://usethinkscript.com/threads/...-first-time-condition-is-met.4574/#post-42198
Any help would be greatly appreciated.
Thanks,
Gary
I tried the code from this post but it misses too many breakouts.
https://usethinkscript.com/threads/...-first-time-condition-is-met.4574/#post-42198
Any help would be greatly appreciated.
Thanks,
Gary
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#
# Input
input tenkan_period = 9;
input kijun_period = 26;
#Plot
plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
plot Kijun = (Highest(high, kijun_period) + Lowest(low, kijun_period)) / 2;
plot SpanA = (Tenkan[kijun_period] + Kijun[kijun_period]) / 2;
plot SpanB = (Highest(high[kijun_period], 2 * kijun_period) + Lowest(low[kijun_period], 2 * kijun_period)) / 2;
plot Chikou = close[-kijun_period];
# Default Colors
Tenkan.SetDefaultColor(CreateColor(255, 126, 156));
Kijun.SetDefaultColor(CreateColor(116, 189, 232));
SpanA.SetDefaultColor(CreateColor(143, 239, 191));
SpanB.SetDefaultColor(CreateColor(246, 188, 179));
Chikou.SetDefaultColor(CreateColor(192, 191, 255));
# Global Kumo Colors
DefineGlobalColor("Bullish", CreateColor(143, 239, 191));
DefineGlobalColor("Bearish", CreateColor(246, 188, 179));
AddCloud(SpanA, SpanB, GlobalColor("Bullish"), GlobalColor("Bearish"));
# Kumo
def highKumoLine = If (SpanA >= SpanB, SpanA, SpanB);
def lowKumoLine = If (SpanA <= SpanB, SpanA, SpanB);
def highKumoLine26 = If (SpanA[26] >= SpanB[26], SpanA[26], SpanB[26]);
def lowKumoLine26 = If (SpanA[26] <= SpanB[26], SpanA[26], SpanB[26]);
def isBullishKumo = SpanA[-26] > SpanB[-26];
def isBearishKumo = SpanA[-26] < SpanB[-26];
def isBullishBreakoutOver = close < lowKumoLine;
def isBearishBreakoutOver = close > highKumoLine;
# Bullish Kumo Breakout
def isBullishKumoBreakout =
close > highKumoLine &&
close > Tenkan &&
close > Kijun &&
Tenkan > highKumoLine &&
Kijun > highKumoLine &&
Tenkan > Kijun &&
close > highKumoLine26 && #chikou
isBullishKumo;
# Bearish Kumo Breakout
def isBearishKumoBreakout =
close < lowKumoLine &&
close < Tenkan &&
close < Kijun &&
Tenkan < lowKumoLine &&
Kijun < lowKumoLine &&
Tenkan < Kijun &&
close < lowKumoLine26 && #chikou
isBearishKumo;
# Only draw one arrow on kumo breakout
def BullishKumoBreakoutActive = if isBullishKumoBreakout then 1 else if !isBearishKumoBreakout then BullishKumoBreakoutActive[1] else 0;
def BearishKumoBreakoutActive = if isBearishKumoBreakout then 1 else if !isBullishKumoBreakout then BearishKumoBreakoutActive[1] else 0;
# Plot bullish kumo breakout
#
#arrow every bar
plot BullishKumoBreakout = isBullishKumoBreakout;
#
#misses breakouts
#plot BullishKumoBreakout = if isBullishKumoBreakout and BearishKumoBreakoutActive[1] == 1 then low else Double.NaN;
BullishKumoBreakout.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BullishKumoBreakout.SetDefaultColor(Color.GREEN);
BullishKumoBreakout.SetLineWeight(3);
# Plot bearish kumo breakout
plot BearishKumoBreakout = isBearishKumoBreakout;
#plot BearishKumoBreakout = if isBearishKumoBreakout and BullishKumoBreakoutActive[1] == 1 then high else Double.NaN;
BearishKumoBreakout.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BearishKumoBreakout.SetDefaultColor(Color.RED);
BearishKumoBreakout.SetLineWeight(3);