Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 31

//@version=4

//By Mihkel00
// This script is designed for the NNFX Method, so it is recommended for Daily
charts only.
// Tried to implement a few VP NNFX Rules
// This script has a SSL / Baseline (you can choose between the SSL or MA), a
secondary SSL for continiuation trades and a third SSL for exit trades.
// Alerts added for Baseline entries, SSL2 continuations, Exits.
// Baseline has a Keltner Channel setting for "in zone" Gray Candles
// Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of
being within Baseline ATR range.
// Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
// Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/
// Moving Averages everget https://www.tradingview.com/u/everget/
// "Many Moving Averages" script Fractured
https://www.tradingview.com/u/Fractured/

study("SMA - SSL Hybrid - HalfTrend - Candelstik Pattern", overlay=true)

///////////////////////////////////////////////////////////////////////////////////
/////////////////////
////ma
srcma1 = input(close, title="SourceMA" ,group="Simple Movinge Average")
lenma1 = input(9, minval=1, title="LengthSMA1" ,group="Simple Movinge Average")
//offsetma1 = input(title="Offset1", defval=0, minval=-500,
maxval=500 ,group="Simple Movinge Average")
outma1 = sma(srcma1, lenma1)
plot(outma1, color=color.yellow, title="SMA1", offset=0)

// ma2
lenma2 = input(55, minval=1, title="LengthSMA2" ,group="Simple Movinge Average")
outma2 = sma(srcma1, lenma2)
plot(outma2, color=color.red, title="SMA2", offset=0, display=display.none)

// ma3
lenma3 = input(200, minval=1, title="LengthSMA3" ,group="Simple Movinge Average")
outma3 = sma(srcma1, lenma3)
plot(outma3, color=color.white, title="SMA3", offset=0, display=display.none)

typeMA = input(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA


(RMA)", "WMA", "VWMA"], group="Smoothing SMA1")
smoothingLength = input(title = "Length Method Smoothing", defval = 5, minval = 1,
maxval = 100, group="Smoothing SMA1")
ShowCrossSma = input(title = "Show Cross Sma" ,defval=false, group="Smoothing
SMA1")
label_SMA_color_bullish_Cross = input(color.aqua, "Label Color Cross Bullish ",
group="Smoothing SMA1")
label_SMA_color_Bearish_Cross = input(color.orange, "Label Color Cross Bearish",
group="Smoothing SMA1")
label_SMA_color_Text_Cross = input(color.white, "Label Text Color",
group="Smoothing SMA1")

//if typeMA == "SMA"

smoothingLine1(srcma11,smoothingLength1) =>
if typeMA == "EMA"
ema(srcma11,smoothingLength1)
else
if typeMA == "SMMA (RMA)"
rma(srcma11,smoothingLength1)
else
if typeMA == "WMA"
wma(srcma11,smoothingLength1)
else
if typeMA == "VWMA"
vwma(srcma11,smoothingLength1)
else
if typeMA == "SMA"
sma(srcma11,smoothingLength1)

smoothingLine = smoothingLine1(srcma1,smoothingLength)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=0)

mylongSma = crossover(smoothingLine,outma1 )
myshortSma = crossunder(smoothingLine,outma1 )

CrossLabelPosLow = low - (atr(40) * 0.9)


CrossLabelPosHigh = high + (atr(40) * 0.9)

alertcondition(mylongSma,"Long / Buy")
alertcondition(myshortSma,"Short / Sell")

if mylongSma and ShowCrossSma


var ttBulishCrossSma = "Bulish Crossed Fast Ema and Smooth Fast Sma"
label.new(bar_index, CrossLabelPosHigh, text="Bull Cross",
style=label.style_label_down, color = label_SMA_color_bullish_Cross,
textcolor=label_SMA_color_Text_Cross, tooltip = ttBulishCrossSma)

if myshortSma and ShowCrossSma


var ttBearishCrossSmaw = "Bearish Crossed Fast Ema and Smooth Fast Sma"
label.new(bar_index, CrossLabelPosLow, text="Bear Cross",
style=label.style_label_up, color = label_SMA_color_Bearish_Cross,
textcolor=label_SMA_color_Text_Cross, tooltip = ttBearishCrossSmaw)

///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////

// HalfTrend1
channelDeviation1 = input(title="HalfTrend Channel Deviation", defval=2 ,group="3
HalfTrend Signal")
amplitude1 = input(title="HalfTrend1 Amplitude", defval=1 ,group="3 HalfTrend
Signal")

//showArrows = input(title="HalfTrend1 Show Arrows", defval=true)


//showChannels = input(title="HalfTrend1 Show Channels", defval=true)

var int trend1 = 0


var int nextTrend1 = 0
var float maxLowPrice1 = nz(low[1], low)
var float minHighPrice1 = nz(high[1], high)
var float up1 = 0.0
var float down1 = 0.0
float atrHigh1 = 0.0
float atrLow1 = 0.0
float arrowUp1 = na
float arrowDown1 = na

atr2 = atr(100) / 2
dev1 = channelDeviation1 * atr2

highPrice1 = high[abs(highestbars(amplitude1))]
lowPrice1 = low[abs(lowestbars(amplitude1))]
highma1 = sma(high, amplitude1)
lowma1 = sma(low, amplitude1)

if nextTrend1 == 1
maxLowPrice1 := max(lowPrice1, maxLowPrice1)

if highma1 < maxLowPrice1 and close < nz(low[1], low)


trend1 := 1
nextTrend1 := 0
minHighPrice1 := highPrice1
else
minHighPrice1 := min(highPrice1, minHighPrice1)

if lowma1 > minHighPrice1 and close > nz(high[1], high)


trend1 := 0
nextTrend1 := 1
maxLowPrice1 := lowPrice1

if trend1 == 0
if not na(trend1[1]) and trend1[1] != 0
up1 := na(down1[1]) ? down1 : down1[1]
arrowUp1 := up1 - atr2
else
up1 := na(up1[1]) ? maxLowPrice1 : max(maxLowPrice1, up1[1])
atrHigh1 := up1 + dev1
atrLow1 := up1 - dev1
else
if not na(trend1[1]) and trend1[1] != 1
down1 := na(up1[1]) ? up1 : up1[1]
arrowDown1 := down1 + atr2
else
down1 := na(down1[1]) ? minHighPrice1 : min(minHighPrice1, down1[1])
atrHigh1 := down1 + dev1
atrLow1 := down1 - dev1

ht1 = trend1 == 0 ? up1 : down1

var color buyColor1 = color.green


var color sellColor1 = color.red

htColor1 = trend1 == 0 ? buyColor1 : sellColor1


htPlot1 = plot(ht1, title="HalfTrend1", linewidth=2, color=htColor1)

//atrHighPlot1 = plot(showChannels1 ? atrHigh1 : na, title="HalfTrend1 ATR High",


style=plot.style_circles, color=sellColor1)
//atrLowPlot1 = plot(showChannels1 ? atrLow1 : na, title="HalfTrend1 ATR Low",
style=plot.style_circles, color=buyColor1)

//fill(htPlot1, atrHighPlot1, title="HalfTrend1 ATR High Ribbon", color=sellColor1)


//fill(htPlot1, atrLowPlot1, title="HalfTrend1 ATR Low Ribbon", color=buyColor1)

//buySignal1 = not na(arrowUp1) and (trend1 == 0 and trend1[1] == 1)


//sellSignal1 = not na(arrowDown1) and (trend1== 1 and trend1[1] == 0)

//plotshape(showArrows and buySignal ? atrLow : na, title="HalfTrend1 Arrow Up",


style=shape.triangleup, location=location.absolute, size=size.tiny, color=buyColor)
//plotshape(showArrows and sellSignal ? atrHigh : na, title="HalfTrend1 Arrow
Down", style=shape.triangledown, location=location.absolute, size=size.tiny,
color=sellColor)

//alertcondition(buySignal, title="Alert: HalfTrend1 Buy", message="HalfTrend1


Buy")
//alertcondition(sellSignal, title="Alert: HalfTrend1 Sell", message="HalfTrend1
Sell")

///////////////////////////////////////////////////////////////////////////////////
/////////////////////////

///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////

// HalfTrend2
//study("HalfTrend", overlay=true)

amplitude2 = input(title="HalfTrend2 Amplitude", defval=2 ,group="3 HalfTrend


Signal")
///channelDeviation2 = input(title="HalfTrend2 Channel Deviation",
defval=2 ,group="3 HalfTrend")
//showArrows = input(title="HalfTrend1 Show Arrows", defval=true)
//showChannels = input(title="HalfTrend1 Show Channels", defval=true)

var int trend2 = 0


var int nextTrend2 = 0
var float maxLowPrice2 = nz(low[1], low)
var float minHighPrice2 = nz(high[1], high)

var float up2 = 0.0


var float down2 = 0.0
float atrHigh2 = 0.0
float atrLow2 = 0.0
float arrowUp2 = na
float arrowDown2 = na

atr22 = atr(100) / 2
dev2 = channelDeviation1 * atr22

highPrice2 = high[abs(highestbars(amplitude2))]
lowPrice2 = low[abs(lowestbars(amplitude2))]
highma2 = sma(high, amplitude2)
lowma2 = sma(low, amplitude2)

if nextTrend2 == 1
maxLowPrice2 := max(lowPrice2, maxLowPrice2)

if highma2 < maxLowPrice2 and close < nz(low[1], low)


trend2 := 1
nextTrend2 := 0
minHighPrice2 := highPrice2
else
minHighPrice2 := min(highPrice2, minHighPrice2)

if lowma2 > minHighPrice2 and close > nz(high[1], high)


trend2 := 0
nextTrend2 := 1
maxLowPrice2 := lowPrice2

if trend2 == 0
if not na(trend2[1]) and trend2[1] != 0
up2 := na(down2[1]) ? down2 : down2[1]
arrowUp2 := up2 - atr22
else
up2 := na(up2[1]) ? maxLowPrice2 : max(maxLowPrice2, up2[1])
atrHigh2 := up2 + dev2
atrLow2 := up2 - dev2
else
if not na(trend2[1]) and trend2[1] != 1
down2 := na(up2[1]) ? up2 : up2[1]
arrowDown2 := down2 + atr22
else
down2 := na(down2[1]) ? minHighPrice2 : min(minHighPrice2, down2[1])
atrHigh2 := down2 + dev2
atrLow2 := down2 - dev2

ht2 = trend2 == 0 ? up2 : down2

var color buyColor2 = color.green


var color sellColor2 = color.red

htColor2 = trend2 == 0 ? buyColor1 : sellColor1


htPlot2 = plot(ht2, title="HalfTrend2", linewidth=2, color=htColor2)

//atrHighPlot = plot(showChannels ? atrHigh : na, title="HalfTrend1 ATR High",


style=plot.style_circles, color=sellColor)
//atrLowPlot = plot(showChannels ? atrLow : na, title="HalfTrend1 ATR Low",
style=plot.style_circles, color=buyColor)

//fill(htPlot, atrHighPlot, title="HalfTrend1 ATR High Ribbon", color=sellColor)


//fill(htPlot, atrLowPlot, title="HalfTrend1 ATR Low Ribbon", color=buyColor)

//buySignal2 = not na(arrowUp2) and (trend2 == 0 and trend2[1] == 1)


//sellSignal2 = not na(arrowDown2) and (trend2 == 1 and trend2[1] == 0)

//plotshape(showArrows and buySignal ? atrLow : na, title="HalfTrend1 Arrow Up",


style=shape.triangleup, location=location.absolute, size=size.tiny, color=buyColor)
//plotshape(showArrows and sellSignal ? atrHigh : na, title="HalfTrend1 Arrow
Down", style=shape.triangledown, location=location.absolute, size=size.tiny,
color=sellColor)

//alertcondition(buySignal, title="Alert: HalfTrend1 Buy", message="HalfTrend1


Buy")
//alertcondition(sellSignal, title="Alert: HalfTrend1 Sell", message="HalfTrend1
Sell")

///////////////////////////////////////////////////////////////////////////////////
/////////////////////////

///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////

// HalfTrend3
//study("HalfTrend", overlay=true)

amplitude3 = input(title="HalfTrend3 Amplitude", defval=3 ,group="3 HalfTrend


Signal")
///channelDeviation3 = input(title="HalfTrend3 Channel Deviation",
defval=2 ,group="3 HalfTrend")
//showArrows = input(title="HalfTrend1 Show Arrows", defval=true)
//showChannels = input(title="HalfTrend1 Show Channels", defval=true)

var int trend3 = 0


var int nextTrend3 = 0
var float maxLowPrice3 = nz(low[1], low)
var float minHighPrice3 = nz(high[1], high)

var float up3 = 0.0


var float down3 = 0.0
float atrHigh3 = 0.0
float atrLow3 = 0.0
float arrowUp3 = na
float arrowDown3 = na

atr23 = atr(100) / 2
dev3 = channelDeviation1 * atr23

highPrice3 = high[abs(highestbars(amplitude3))]
lowPrice3 = low[abs(lowestbars(amplitude3))]
highma3 = sma(high, amplitude3)
lowma3 = sma(low, amplitude3)

if nextTrend3 == 1
maxLowPrice3 := max(lowPrice3, maxLowPrice3)

if highma3 < maxLowPrice3 and close < nz(low[1], low)


trend3 := 1
nextTrend3 := 0
minHighPrice3 := highPrice3
else
minHighPrice3 := min(highPrice3, minHighPrice3)

if lowma3 > minHighPrice3 and close > nz(high[1], high)


trend3 := 0
nextTrend3 := 1
maxLowPrice3 := lowPrice3

if trend3 == 0
if not na(trend3[1]) and trend3[1] != 0
up3 := na(down3[1]) ? down3 : down3[1]
arrowUp3 := up3 - atr23
else
up3 := na(up3[1]) ? maxLowPrice3 : max(maxLowPrice3, up3[1])
atrHigh3 := up3 + dev3
atrLow3 := up3 - dev3
else
if not na(trend3[1]) and trend3[1] != 1
down3 := na(up3[1]) ? up3 : up3[1]
arrowDown3 := down3 + atr23
else
down3 := na(down3[1]) ? minHighPrice3 : min(minHighPrice3, down3[1])
atrHigh3 := down3 + dev3
atrLow3 := down3 - dev3

ht3 = trend3 == 0 ? up3 : down3

var color buyColor3 = color.green


var color sellColor3 = color.red

htColor3 = trend3 == 0 ? buyColor3 : sellColor3


htPlot3 = plot(ht3, title="HalfTrend3", linewidth=2, color=htColor3)

//atrHighPlot = plot(showChannels ? atrHigh : na, title="HalfTrend1 ATR High",


style=plot.style_circles, color=sellColor)
//atrLowPlot = plot(showChannels ? atrLow : na, title="HalfTrend1 ATR Low",
style=plot.style_circles, color=buyColor)

//fill(htPlot, atrHighPlot, title="HalfTrend1 ATR High Ribbon", color=sellColor)


//fill(htPlot, atrLowPlot, title="HalfTrend1 ATR Low Ribbon", color=buyColor)

//buySignal3 = not na(arrowUp3) and (trend3 == 0 and trend3[1] == 1)


//sellSignal3 = not na(arrowDown3) and (trend3 == 1 and trend3[1] == 0)

//plotshape(showArrows and buySignal ? atrLow : na, title="HalfTrend1 Arrow Up",


style=shape.triangleup, location=location.absolute, size=size.tiny, color=buyColor)
//plotshape(showArrows and sellSignal ? atrHigh : na, title="HalfTrend1 Arrow
Down", style=shape.triangledown, location=location.absolute, size=size.tiny,
color=sellColor)

//alertcondition(buySignal, title="Alert: HalfTrend1 Buy", message="HalfTrend1


Buy")
//alertcondition(sellSignal, title="Alert: HalfTrend1 Sell", message="HalfTrend1
Sell")

///////////////////////////////////////////////////////////////////////////////////
///
//indicator(title="Ichimoku Cloud", shorttitle="Ichimoku", overlay=true)
conversionPeriods = input(9, minval=1, title="Conversion Line Length",
group="ichimoku and SSL Hybrid Signal")
basePeriods = input(26, minval=1, title="Base Line Length", group="ichimoku and SSL
Hybrid Signal")
ShowCrossIchi = input(title = "Show Cross ichimocu" ,defval=false, group="ichimoku
and SSL Hybrid Signal")

//laggingSpan2Periods = input(52, minval=1, title="Leading Span B Length")


//displacement = input(26, minval=1, title="Lagging Span")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
//leadLine1 = math.avg(conversionLine, baseLine)
//leadLine2 = donchian(laggingSpan2Periods)

LongCrossIchi = crossover(conversionLine,baseLine )
ShortCrossIchi = crossunder(conversionLine,baseLine )
CrossLabelichiLow = low - (atr(30) * 0.8)
CrossLabelichiHigh = high + (atr(30) * 0.8)

alertcondition(LongCrossIchi,"Long / Buy")
alertcondition(ShortCrossIchi,"Short / Sell")

label_ICHI_color_bullish_Cross = input(color.lime, "Label Color Cross Bullish ",


group="ichimoku and SSL Hybrid Signal")
label_ICHI_color_Bearish_Cross = input(color.maroon, "Label Color Cross Bearish",
group="ichimoku and SSL Hybrid Signal")
label_ICHI_color_Text_Cross = input(color.white, "Label Color Cross Bearish",
group="ichimoku and SSL Hybrid Signal")

if LongCrossIchi and ShowCrossIchi


var ttBulishCrossIchi = "Bulish Crossed Ichimoku conversion line and base line"
label.new(bar_index, CrossLabelichiLow, text="Bull Cross ichi",
style=label.style_label_up, color =label_ICHI_color_bullish_Cross,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBulishCrossIchi)

if ShortCrossIchi and ShowCrossIchi


var ttBearishCrossIchi = "Bearish Crossed Ichimoku conversion line and base
line"
label.new(bar_index, CrossLabelichiHigh, text="Bear Cross ichi",
style=label.style_label_down, color = label_ICHI_color_Bearish_Cross,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishCrossIchi)

plot(conversionLine, color=#2962FF, title="Conversion Line")


plot(baseLine, color=#B71C1C, title="Base Line")
//plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")
//p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
// title="Leading Span A")
//p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
// title="Leading Span B")
//fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) :
color.rgb(244, 67, 54, 90))

///////////////////////////////////////////////////////////////////////////////////
///

show_Baseline = bool(false)//(false,title="Show Baseline", type=input.bool)


show_SSL1 = bool(false)//input(title="Show SSL1", type=input.bool, defval=false)
//show_atr = input(title="Show ATR bands", type=input.bool, defval=true)
//ATR

maType = input(title="SSL1 / Baseline Type", type=input.string, defval="Kijun v2",


options=["SMA","EMA","DEMA","TEMA","LSMA","WMA","MF","VAMA","TMA","HMA", "JMA",
"Kijun v2", "EDSMA","McGinley"], group="ichimoku and SSL Hybrid Signal")
len = input(title="SSL1 / Baseline Length", defval=60, group="ichimoku and SSL
Hybrid Signal")
atrlen =int(14) // input(14, "ATR Period")
mult = int(1)
smoothing = input(title="ATR Smoothing", defval="WMA", options=["RMA", "SMA",
"EMA", "WMA"], group="ichimoku and SSL Hybrid Signal")

ma_function(source, atrlen) =>


if smoothing == "RMA"
rma(source, atrlen)
else
if smoothing == "SMA"
sma(source, atrlen)
else
if smoothing == "EMA"
ema(source, atrlen)
else
wma(source, atrlen)
atr_slen = ma_function(tr(true), atrlen)
////ATR Up/Low Bands
upper_band = atr_slen * mult + close
lower_band = close - atr_slen * mult

////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES

SSL2Type = input(title="SSL2 / Continuation Type", type=input.string, defval="JMA",


options=["SMA","EMA","DEMA","TEMA","WMA","MF","VAMA","TMA","HMA",
"JMA","McGinley"], group="ichimoku and SSL Hybrid Signal")
len2 = int(5)
//
SSL3Type = input(title="EXIT Type", type=input.string, defval="HMA",
options=["DEMA","TEMA","LSMA","VAMA","TMA","HMA","JMA", "Kijun v2", "McGinley",
"MF"], group="ichimoku and SSL Hybrid Signal")
len3 = int(15)
src = input(title="Source", type=input.source, defval=close, group="ichimoku and
SSL Hybrid Signal")

//
tema(src, len) =>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
(3 * ema1) - (3 * ema2) + ema3
kidiv = int(1)
jurik_phase = int(3)
jurik_power = int(1)
volatility_lookback = int(10)
//MF
beta = int(0.8)
feedback = bool(false)
z = int(0.5)
//EDSMA
ssfLength = int(20)
ssfPoles = int(2)

//----

//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3

ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])

get3PoleSSF(src, length) =>


PI = 2 * asin(1)

arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)

coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4

ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 *
nz(ssf[3])

ma(type, src, len) =>


float result = 0
if type=="TMA"
result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
if type=="MF"
ts=0.,b=0.,c=0.,os=0.
//----
alpha = 2/(len+1)
a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
//----
b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
os := a == b ? 1 : a == c ? 0 : os[1]
//----
upper = beta*b+(1-beta)*c
lower = beta*c+(1-beta)*b
ts := os*upper+(1-os)*lower
result := ts
if type=="LSMA"
result := linreg(src, len, 0)
if type=="SMA" // Simple
result := sma(src, len)
if type=="EMA" // Exponential
result := ema(src, len)
if type=="DEMA" // Double Exponential
e = ema(src, len)
result := 2 * e - ema(e, len)
if type=="TEMA" // Triple Exponential
e = ema(src, len)
result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
if type=="WMA" // Weighted
result := wma(src, len)
if type=="VAMA" // Volatility Adjusted
/// Copyright © 2019 to present, Joris Duyck (JD)
mid=ema(src,len)
dev=src-mid
vol_up=highest(dev,volatility_lookback)
vol_down=lowest(dev,volatility_lookback)
result := mid+avg(vol_up,vol_down)
if type=="HMA" // Hull
result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
if type=="JMA" // Jurik
/// Copyright © 2018 Alex Orekhov (everget)
/// Copyright © 2017 Jurik Research and Consulting.
phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 :
jurik_phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = pow(beta, jurik_power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha,
2) * nz(e2[1])
jma := e2 + nz(jma[1])
result := jma
if type=="Kijun v2"
kijun = avg(lowest(len), highest(len))//, (open + close)/2)
conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))
delta = (kijun + conversionLine)/2
result :=delta
if type=="McGinley"
mg = 0.0
mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len *
pow(src/mg[1], 4))
result :=mg
if type=="EDSMA"

zeros = src - nz(src[2])


avgZeros = (zeros + zeros[1]) / 2

// Ehlers Super Smoother Filter


ssf = ssfPoles == 2
? get2PoleSSF(avgZeros, ssfLength)
: get3PoleSSF(avgZeros, ssfLength)

// Rescale filter in terms of Standard Deviations


stdev = stdev(ssf, len)
scaledFilter = stdev != 0
? ssf / stdev
: 0

alpha = 5 * abs(scaledFilter) / len

edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result

///SSL 1 and SSL2


emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)

maHigh = ma(SSL2Type, high, len2)


maLow = ma(SSL2Type, low, len2)

///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)

///Keltner Baseline Channel


BBMC = ma(maType, close, len)
useTrueRange = input(true)
multy = int(0.2)
Keltma = ma(maType, src, len)
range1 = useTrueRange ? tr : high - low
rangema = ema(range1, len)
upperk =Keltma + rangema * multy
lowerk = Keltma - rangema * multy

//Baseline Violation Candle


open_pos = open*1
close_pos = close*1
difference = abs(close_pos-open_pos)
atr_violation = difference > atr_slen
InRange = upper_band > BBMC and lower_band < BBMC
candlesize_violation = atr_violation and InRange
//plotshape(candlesize_violation, color=label_ICHI_color_Text_Cross,
size=size.tiny,style=shape.diamond, location=location.top, transp=0,title="Candle
Size > 1xATR")

///////////////////////////////////////////////////////////////////////////////////
/////////////////////
//SSL1 VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow

//SSL2 VALUES
Hlv2 = int(na)
Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
sslDown2 = Hlv2 < 0 ? maHigh : maLow

//EXIT VALUES
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = crossover(close, sslExit)
base_cross_Short = crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na

//COLORS
show_color_bar = input(title="Color Bars", type=input.bool, defval=true,
group="ichimoku and SSL Hybrid Signal")
color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray
color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na

//PLOTS
plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows",
transp=20, maxheight=20)
//p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4,transp=0,
title='MA Baseline')
//DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3,
color=color_ssl1, transp=10)
barcolor(show_color_bar ? color_bar : na)
//up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline
Upper Channel")
//low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title="Basiline
Lower Channel")
//fill(up_channel, low_channel, color=color_bar, transp=90)

////SSL2 Continiuation from ATR


atr_crit = int(0.9)
upper_half = atr_slen * atr_crit + close
lower_half = close - atr_slen * atr_crit
buy_inatr = lower_half < sslDown2
sell_inatr = upper_half > sslDown2
sell_cont = close < BBMC and close < sslDown2
buy_cont = close > BBMC and close > sslDown2
sell_atr = sell_inatr and sell_cont
buy_atr = buy_inatr and buy_cont
atr_fill = buy_atr ? color.green : sell_atr ? color.purple :
label_ICHI_color_Text_Cross
//LongPlot = plot(sslDown2, title="SSL2", linewidth=2, color=atr_fill,
style=plot.style_circles, transp=0)
//u = plot(show_atr ? upper_band : na, "+ATR", color=label_ICHI_color_Text_Cross,
transp=80)
//l = plot(show_atr ? lower_band : na, "-ATR", color=label_ICHI_color_Text_Cross,
transp=80)
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////

//ALERTS
//alertcondition(crossover(close, sslDown), title='SSL Cross Alert', message='SSL1
has crossed.')
//alertcondition(crossover(close, sslDown2), title='SSL2 Cross Alert',
message='SSL2 has crossed.')
//alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
//alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
//alertcondition(crossover(close, sslExit), title='Exit Sell', message='Exit Sell
Alert.')
//alertcondition(crossover(sslExit, close), title='Exit Buy', message='Exit Buy
Alert.')
//alertcondition(crossover(close, upperk ), title='Baseline Buy Entry',
message='Base Buy Alert.')
//alertcondition(crossover(lowerk, close ), title='Baseline Sell Entry',
message='Base Sell Alert.')
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////
// candleasic

C_DownTrend = true
C_UpTrend = true

var trendRule1 = "SMA55"


var trendRule2 = "SMA55, SMA200"
var trendRule = input(trendRule1, "Detect Trend Based On", options=[trendRule1,
trendRule2, "No detection"], group="Candleasic Pattern")

if trendRule == trendRule1
priceAvg = sma(close, 55)
C_DownTrend := close < priceAvg
C_UpTrend := close > priceAvg

if trendRule == trendRule2
sma200 = sma(close, 200)
sma50 = sma(close, 55)
C_DownTrend := close < sma50 and sma50 < sma200
C_UpTrend := close > sma50 and sma50 > sma200
C_Len = 14 // ta.ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick
body

C_BodyHi = max(close, open)


C_BodyLo = min(close, open)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = high - C_BodyHi
C_DnShadow = C_BodyLo - low
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = open < close
C_BlackBody = open > close
C_Range = high-low
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
C_ShadowEquals = C_UpShadow == C_DnShadow or (abs(C_UpShadow - C_DnShadow) /
C_DnShadow * 100) < C_ShadowEqualsPercent and (abs(C_DnShadow - C_UpShadow) /
C_UpShadow * 100) < C_ShadowEqualsPercent
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals

patternLabelPosLow = low - (atr(30) * 0.6)


patternLabelPosHigh = high + (atr(30) * 0.6)

label_color_bullish = input(color.green, "Label Color Bullish", group="Candleasic


Pattern")
label_color_bearish = input(color.red, "Label Color Bearish", group="Candleasic
Pattern")
label_color_neutral = input(color.gray, "Label Color Neutral", group="Candleasic
Pattern")
CandleType = input(title = "Pattern Type", defval="Both", options=["Bullish",
"Bearish", "Both"], group="Candleasic Pattern")

AbandonedBabyInput = input(title = "Abandoned Baby" ,defval=true, group="Candleasic


Pattern")

DarkCloudCoverInput = input(title = "Dark Cloud Cover" ,defval=false,


group="Candleasic Pattern")

// DojiInput = input(title = "Doji" ,defval=true)

//DojiStarInput = input(title = "Doji Star" ,defval=false)

ThreeShadowBullInput = input(title = "Three Shadow Bulish" ,defval=false,


group="Candleasic Pattern")

//ThreeShadowBearInput = input(title = "Three Shadow Bearish" ,defval=false,


group="Candleasic Pattern")

DownsideTasukiGapInput = input(title = "Downside Tasuki Gap" ,defval=false,


group="Candleasic Pattern")

DragonflyDojiInput = input(title = "Dragonfly Doji" ,defval=true, group="Candleasic


Pattern")

EngulfingInput = input(title = "Engulfing" ,defval=true, group="Candleasic


Pattern")

EveningDojiStarInput = input(title = "Evening Doji Star" ,defval=false,


group="Candleasic Pattern")

EveningStarInput = input(title = "Evening Star" ,defval=false, group="Candleasic


Pattern")

FallingThreeMethodsInput = input(title = "Falling Three Methods" ,defval=false,


group="Candleasic Pattern")

FallingWindowInput = input(title = "Falling Window" ,defval=false,


group="Candleasic Pattern")

GravestoneDojiInput = input(title = "Gravestone Doji" ,defval=false,


group="Candleasic Pattern")

HammerInput = input(title = "Hammer" ,defval=true, group="Candleasic Pattern")

HangingManInput = input(title = "Hanging Man" ,defval=false, group="Candleasic


Pattern")

HaramiCrossInput = input(title = "Harami Cross" ,defval=false, group="Candleasic


Pattern")

HaramiInput = input(title = "Harami" ,defval=false, group="Candleasic Pattern")

InvertedHammerInput = input(title = "Inverted Hammer" ,defval=false,


group="Candleasic Pattern")

KickingInput = input(title = "Kicking" ,defval=false, group="Candleasic Pattern")


LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=false,
group="Candleasic Pattern")

LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=false,


group="Candleasic Pattern")

MarubozuBlackInput = input(title = "Marubozu Black" ,defval=false,


group="Candleasic Pattern")

MarubozuWhiteInput = input(title = "Marubozu White" ,defval=false,


group="Candleasic Pattern")

MorningDojiStarInput = input(title = "Morning Doji Star" ,defval=false,


group="Candleasic Pattern")

MorningStarInput = input(title = "Morning Star" ,defval=false, group="Candleasic


Pattern")

OnNeckInput = input(title = "On Neck" ,defval=false, group="Candleasic Pattern")

PiercingInput = input(title = "Piercing" ,defval=false, group="Candleasic Pattern")

RisingThreeMethodsInput = input(title = "Rising Three Methods" ,defval=false,


group="Candleasic Pattern")

RisingWindowInput = input(title = "Rising Window" ,defval=false, group="Candleasic


Pattern")

ShootingStarInput = input(title = "Shooting Star" ,defval=false, group="Candleasic


Pattern")

SpinningTopBlackInput = input(title = "Spinning Top Black" ,defval=false,


group="Candleasic Pattern")

SpinningTopWhiteInput = input(title = "Spinning Top White" ,defval=false,


group="Candleasic Pattern")

ThreeBlackCrowsInput = input(title = "Three Black Crows" ,defval=false,


group="Candleasic Pattern")

ThreeWhiteSoldiersInput = input(title = "Three White Soldiers" ,defval=true,


group="Candleasic Pattern")

TriStarInput = input(title = "Tri-Star" ,defval=false, group="Candleasic Pattern")

TweezerBottomInput = input(title = "Tweezer Bottom" ,defval=false,


group="Candleasic Pattern")

TweezerTopInput = input(title = "Tweezer Top" ,defval=false, group="Candleasic


Pattern")

UpsideTasukiGapInput = input(title = "Upside Tasuki Gap" ,defval=false,


group="Candleasic Pattern")

C_OnNeckBearishNumberOfCandles = 2
C_OnNeckBearish = false
if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open <
close[1] and C_SmallBody and C_Range!=0 and abs(close-low[1])<=C_BodyAvg*0.05
C_OnNeckBearish := true
alertcondition(C_OnNeckBearish, title = "On Neck – Bearish", message = "New On Neck
– Bearish pattern detected")
if C_OnNeckBearish and OnNeckInput and (("Bearish" == CandleType) or CandleType
== "Both")

var ttBearishOnNeck = "On Neck\nOn Neck is a two-line continuation pattern


found in a downtrend. The first candle is long and red, the second candle is short
and has a green body. The closing price of the second candle is close or equal to
the first candle's low price. The pattern hints at a continuation of a downtrend,
and penetrating the low of the green candlestick is sometimes considered a
confirmation. "
label.new(bar_index, patternLabelPosHigh, text="ON",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishOnNeck)
C_RisingWindowBullishNumberOfCandles = 2
C_RisingWindowBullish = false
if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1]
C_RisingWindowBullish := true
alertcondition(C_RisingWindowBullish, title = "Rising Window – Bullish", message =
"New Rising Window – Bullish pattern detected")
if C_RisingWindowBullish and RisingWindowInput and (("Bullish" == CandleType) or
CandleType == "Both")

var ttBullishRisingWindow = "Rising Window\nRising Window is a two-candle


bullish continuation pattern that forms during an uptrend. Both candles in the
pattern can be of any type with the exception of the Four-Price Doji. The most
important characteristic of the pattern is a price gap between the first candle's
high and the second candle's low. That gap (window) between two bars signifies
support against the selling pressure."
label.new(bar_index, patternLabelPosLow, text="RW", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishRisingWindow)
C_FallingWindowBearishNumberOfCandles = 2
C_FallingWindowBearish = false
if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1]
C_FallingWindowBearish := true
alertcondition(C_FallingWindowBearish, title = "Falling Window – Bearish", message
= "New Falling Window – Bearish pattern detected")
if C_FallingWindowBearish and FallingWindowInput and (("Bearish" == CandleType)
or CandleType == "Both")

var ttBearishFallingWindow = "Falling Window\nFalling Window is a two-candle


bearish continuation pattern that forms during a downtrend. Both candles in the
pattern can be of any type, with the exception of the Four-Price Doji. The most
important characteristic of the pattern is a price gap between the first candle's
low and the second candle's high. The existence of this gap (window) means that the
bearish trend is expected to continue."
label.new(bar_index, patternLabelPosHigh, text="FW",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishFallingWindow)
C_FallingThreeMethodsBearishNumberOfCandles = 5
C_FallingThreeMethodsBearish = false
if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and
C_WhiteBody[3] and open[3]>low[4] and close[3]<high[4]) and (C_SmallBody[2] and
C_WhiteBody[2] and open[2]>low[4] and close[2]<high[4]) and (C_SmallBody[1] and
C_WhiteBody[1] and open[1]>low[4] and close[1]<high[4]) and (C_LongBody and
C_BlackBody and close<close[4])
C_FallingThreeMethodsBearish := true
alertcondition(C_FallingThreeMethodsBearish, title = "Falling Three Methods –
Bearish", message = "New Falling Three Methods – Bearish pattern detected")
if C_FallingThreeMethodsBearish and FallingThreeMethodsInput and (("Bearish" ==
CandleType) or CandleType == "Both")

var ttBearishFallingThreeMethods = "Falling Three Methods\nFalling Three


Methods is a five-candle bearish pattern that signifies a continuation of an
existing downtrend. The first candle is long and red, followed by three short green
candles with bodies inside the range of the first candle. The last candle is also
red and long and it closes below the close of the first candle. This decisive fifth
strongly bearish candle hints that bulls could not reverse the prior downtrend and
that bears have regained control of the market."
label.new(bar_index, patternLabelPosHigh, text="FTM",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishFallingThreeMethods)
C_RisingThreeMethodsBullishNumberOfCandles = 5
C_RisingThreeMethodsBullish = false
if C_UpTrend[4] and (C_LongBody[4] and C_WhiteBody[4]) and (C_SmallBody[3] and
C_BlackBody[3] and open[3]<high[4] and close[3]>low[4]) and (C_SmallBody[2] and
C_BlackBody[2] and open[2]<high[4] and close[2]>low[4]) and (C_SmallBody[1] and
C_BlackBody[1] and open[1]<high[4] and close[1]>low[4]) and (C_LongBody and
C_WhiteBody and close>close[4])
C_RisingThreeMethodsBullish := true
alertcondition(C_RisingThreeMethodsBullish, title = "Rising Three Methods –
Bullish", message = "New Rising Three Methods – Bullish pattern detected")
if C_RisingThreeMethodsBullish and RisingThreeMethodsInput and (("Bullish" ==
CandleType) or CandleType == "Both")

var ttBullishRisingThreeMethods = "Rising Three Methods\nRising Three Methods


is a five-candle bullish pattern that signifies a continuation of an existing
uptrend. The first candle is long and green, followed by three short red candles
with bodies inside the range of the first candle. The last candle is also green and
long and it closes above the close of the first candle. This decisive fifth
strongly bullish candle hints that bears could not reverse the prior uptrend and
that bulls have regained control of the market."
label.new(bar_index, patternLabelPosLow, text="RTM",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishRisingThreeMethods)
C_TweezerTopBearishNumberOfCandles = 2
C_TweezerTopBearish = false
//if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and
abs(high-high[1]) <= C_BodyAvg*0.05 and C_WhiteBody[1] and C_BlackBody and
C_LongBody[1]
if not C_IsDojiBody and (C_Body * 0.2 > C_UpShadow) and (C_Body[1] * 0.2 >
C_UpShadow[1]) and (((C_Body <= C_Body[1] * 1.1) and (C_Body > C_Body[1] * 0.9)) or
((C_Body[1] <= C_Body * 1.1) and (C_Body[1] > C_Body * 0.9))) and (close[1] <
close) and open[1] > open // and (close[1]>= open*0.95) and (close[1]<open*1.05) //
or ( (close[1]<close) and (close[1]<=open*1.05) and (close[1]>open*0.95) ))
C_TweezerTopBearish := true
alertcondition(C_TweezerTopBearish, title = "Tweezer Top – Bearish", message = "New
Tweezer Top – Bearish pattern detected")
if C_TweezerTopBearish and TweezerTopInput and (("Bearish" == CandleType) or
CandleType == "Both")

var ttBearishTweezerTop = "Tweezer Top\nTweezer Top is a two-candle pattern


that signifies a potential bearish reversal. The pattern is found during an
uptrend. The first candle is long and green, the second candle is red, and its high
is nearly identical to the high of the previous candle. The virtually identical
highs, together with the inverted directions, hint that bears might be taking over
the market."
label.new(bar_index, patternLabelPosHigh, text="TT",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishTweezerTop)

C_TweezerBottomBullishNumberOfCandles = 2
C_TweezerBottomBullish = false
if C_DownTrend[1] and not C_IsDojiBody and (C_Body * 0.2 > C_DnShadow) and
(C_Body[1] * 0.2 > C_DnShadow[1]) and (((C_Body <= C_Body[1] * 1.1) and (C_Body >
C_Body[1] * 0.9)) or ((C_Body[1] <= C_Body * 1.1) and (C_Body[1] > C_Body * 0.9)))
and (close[1] < close) and open[1] > open // and (close[1]>= open*0.95) and
(close[1]<open*1.05) // or ( (close[1]<close) and (close[1]<=open*1.05) and
(close[1]>open*0.95) ))
C_TweezerBottomBullish := true
alertcondition(C_TweezerBottomBullish, title = "Tweezer Bottom – Bullish", message
= "New Tweezer Bottom – Bullish pattern detected")
if C_TweezerBottomBullish and TweezerBottomInput and (("Bullish" == CandleType)
or CandleType == "Both")

var ttBullishTweezerBottom = "Tweezer Bottom\nTweezer Bottom is a two-candle


pattern that signifies a potential bullish reversal. The pattern is found during a
downtrend. The first candle is long and red, the second candle is green, its lows
nearly identical to the low of the previous candle. The virtually identical lows
together with the inverted directions hint that bulls might be taking over the
market."
label.new(bar_index, patternLabelPosLow, text="TB", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishTweezerBottom)
C_DarkCloudCoverBearishNumberOfCandles = 2
C_DarkCloudCoverBearish = false
if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and open >=
high[1] and close < C_BodyMiddle[1] and close > open[1])
C_DarkCloudCoverBearish := true
alertcondition(C_DarkCloudCoverBearish, title = "Dark Cloud Cover – Bearish",
message = "New Dark Cloud Cover – Bearish pattern detected")
if C_DarkCloudCoverBearish and DarkCloudCoverInput and (("Bearish" == CandleType)
or CandleType == "Both")

var ttBearishDarkCloudCover = "Dark Cloud Cover\nDark Cloud Cover is a two-


candle bearish reversal candlestick pattern found in an uptrend. The first candle
is green and has a larger than average body. The second candle is red and opens
above the high of the prior candle, creating a gap, and then closes below the
midpoint of the first candle. The pattern shows a possible shift in the momentum
from the upside to the downside, indicating that a reversal might happen soon."
label.new(bar_index, patternLabelPosHigh, text="DCC",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishDarkCloudCover)
C_DownsideTasukiGapBearishNumberOfCandles = 3
C_DownsideTasukiGapBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and
C_BodyHi[1] < C_BodyLo[2] and C_BlackBody[1] and C_WhiteBody and C_BodyHi <=
C_BodyLo[2] and C_BodyHi >= C_BodyHi[1]
C_DownsideTasukiGapBearish := true
alertcondition(C_DownsideTasukiGapBearish, title = "Downside Tasuki Gap – Bearish",
message = "New Downside Tasuki Gap – Bearish pattern detected")
if C_DownsideTasukiGapBearish and DownsideTasukiGapInput and (("Bearish" ==
CandleType) or CandleType == "Both")
var ttBearishDownsideTasukiGap = "Downside Tasuki Gap\nDownside Tasuki Gap is a
three-candle pattern found in a downtrend that usually hints at the continuation of
the downtrend. The first candle is long and red, followed by a smaller red candle
with its opening price that gaps below the body of the previous candle. The third
candle is green and it closes inside the gap created by the first two candles,
unable to close it fully. The bull’s inability to close that gap hints that the
downtrend might continue."
label.new(bar_index, patternLabelPosHigh, text="DTG",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishDownsideTasukiGap)
C_UpsideTasukiGapBullishNumberOfCandles = 3
C_UpsideTasukiGapBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and
C_BodyLo[1] > C_BodyHi[2] and C_WhiteBody[1] and C_BlackBody and C_BodyLo >=
C_BodyHi[2] and C_BodyLo <= C_BodyLo[1]
C_UpsideTasukiGapBullish := true
alertcondition(C_UpsideTasukiGapBullish, title = "Upside Tasuki Gap – Bullish",
message = "New Upside Tasuki Gap – Bullish pattern detected")
if C_UpsideTasukiGapBullish and UpsideTasukiGapInput and (("Bullish" ==
CandleType) or CandleType == "Both")

var ttBullishUpsideTasukiGap = "Upside Tasuki Gap\nUpside Tasuki Gap is a


three-candle pattern found in an uptrend that usually hints at the continuation of
the uptrend. The first candle is long and green, followed by a smaller green candle
with its opening price that gaps above the body of the previous candle. The third
candle is red and it closes inside the gap created by the first two candles, unable
to close it fully. The bear’s inability to close the gap hints that the uptrend
might continue."
label.new(bar_index, patternLabelPosLow, text="UTG",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishUpsideTasukiGap)
C_EveningDojiStarBearishNumberOfCandles = 3
C_EveningDojiStarBearish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and
C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <=
C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi
C_EveningDojiStarBearish := true
alertcondition(C_EveningDojiStarBearish, title = "Evening Doji Star – Bearish",
message = "New Evening Doji Star – Bearish pattern detected")
if C_EveningDojiStarBearish and EveningDojiStarInput and (("Bearish" ==
CandleType) or CandleType == "Both")

var ttBearishEveningDojiStar = "Evening Doji Star\nThis candlestick pattern is


a variation of the Evening Star pattern. It is bearish and continues an uptrend
with a long-bodied, green candle day. It is then followed by a gap and a Doji
candle and concludes with a downward close. The close would be below the first
day’s midpoint. It is more bearish than the regular evening star pattern because of
the existence of the Doji."
label.new(bar_index, patternLabelPosHigh, text="EDS",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishEveningDojiStar)
//C_DojiStarBearishNumberOfCandles = 2
//C_DojiStarBearish = false
//if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo >
C_BodyHi[1]
// C_DojiStarBearish := true
//alertcondition(C_DojiStarBearish, title = "Doji Star – Bearish", message = "New
Doji Star – Bearish pattern detected")
//if C_DojiStarBearish and DojiStarInput and (("Bearish" == CandleType) or
CandleType == "Both")

// var ttBearishDojiStar = "Doji Star\nThis is a bearish reversal candlestick


pattern that is found in an uptrend and consists of two candles. First comes a long
green candle, followed by a Doji candle (except 4-Price Doji) that opens above the
body of the first one, creating a gap. It is considered a reversal signal with
confirmation during the next trading day."
// label.new(bar_index, patternLabelPosHigh, text="DS",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishDojiStar)
//C_DojiStarBullishNumberOfCandles = 2
//C_DojiStarBullish = false
//if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi
< C_BodyLo[1]
// C_DojiStarBullish := true
//alertcondition(C_DojiStarBullish, title = "Doji Star – Bullish", message = "New
Doji Star – Bullish pattern detected")
//if C_DojiStarBullish and DojiStarInput and (("Bullish" == CandleType) or
CandleType == "Both")

// var ttBullishDojiStar = "Doji Star\nThis is a bullish reversal candlestick


pattern that is found in a downtrend and consists of two candles. First comes a
long red candle, followed by a Doji candle (except 4-Price Doji) that opens below
the body of the first one, creating a gap. It is considered a reversal signal with
confirmation during the next trading day."
// label.new(bar_index, patternLabelPosLow, text="DS",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishDojiStar)
C_MorningDojiStarBullishNumberOfCandles = 3
C_MorningDojiStarBullish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and
C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >=
C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo
C_MorningDojiStarBullish := true
alertcondition(C_MorningDojiStarBullish, title = "Morning Doji Star – Bullish",
message = "New Morning Doji Star – Bullish pattern detected")
if C_MorningDojiStarBullish and MorningDojiStarInput and (("Bullish" ==
CandleType) or CandleType == "Both")

var ttBullishMorningDojiStar = "Morning Doji Star\nThis candlestick pattern is


a variation of the Morning Star pattern. A three-day bullish reversal pattern,
which consists of three candlesticks will look something like this: The first being
a long-bodied red candle that extends the current downtrend. Next comes a Doji that
gaps down on the open. After that comes a long-bodied green candle, which gaps up
on the open and closes above the midpoint of the body of the first day. It is more
bullish than the regular morning star pattern because of the existence of the
Doji."
label.new(bar_index, patternLabelPosLow, text="MDS",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishMorningDojiStar)
C_PiercingBullishNumberOfCandles = 2
C_PiercingBullish = false
if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and open
<= low[1] and close > C_BodyMiddle[1] and close < open[1])
C_PiercingBullish := true
alertcondition(C_PiercingBullish, title = "Piercing – Bullish", message = "New
Piercing – Bullish pattern detected")
if C_PiercingBullish and PiercingInput and (("Bullish" == CandleType) or
CandleType == "Both")
var ttBullishPiercing = "Piercing\nPiercing is a two-candle bullish reversal
candlestick pattern found in a downtrend. The first candle is red and has a larger
than average body. The second candle is green and opens below the low of the prior
candle, creating a gap, and then closes above the midpoint of the first candle. The
pattern shows a possible shift in the momentum from the downside to the upside,
indicating that a reversal might happen soon."
label.new(bar_index, patternLabelPosLow, text="P", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishPiercing)
C_HammerBullishNumberOfCandles = 1
C_HammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor *
C_Body and not C_HasUpShadow
if C_DownTrend
C_HammerBullish := true
alertcondition(C_HammerBullish, title = "Hammer – Bullish", message = "New Hammer –
Bullish pattern detected")
if C_HammerBullish and HammerInput and (("Bullish" == CandleType) or CandleType
== "Both")

var ttBullishHammer = "Hammer\nHammer candlesticks form when a security moves


lower after the open, but continues to rally into close above the intraday low. The
candlestick that you are left with will look like a square attached to a long
stick-like figure. This candlestick is called a Hammer if it happens to form during
a decline."
label.new(bar_index, patternLabelPosLow, text="H", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishHammer)
C_HangingManBearishNumberOfCandles = 1
C_HangingManBearish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor *
C_Body and not C_HasUpShadow
if C_UpTrend
C_HangingManBearish := true
alertcondition(C_HangingManBearish, title = "Hanging Man – Bearish", message = "New
Hanging Man – Bearish pattern detected")
if C_HangingManBearish and HangingManInput and (("Bearish" == CandleType) or
CandleType == "Both")

var ttBearishHangingMan = "Hanging Man\nWhen a specified security notably moves


lower after the open, but continues to rally to close above the intraday low, a
Hanging Man candlestick will form. The candlestick will resemble a square, attached
to a long stick-like figure. It is referred to as a Hanging Man if the candlestick
forms during an advance."
label.new(bar_index, patternLabelPosHigh, text="HM",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishHangingMan)
C_ShootingStarBearishNumberOfCandles = 1
C_ShootingStarBearish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor *
C_Body and not C_HasDnShadow
if C_UpTrend
C_ShootingStarBearish := true
alertcondition(C_ShootingStarBearish, title = "Shooting Star – Bearish", message =
"New Shooting Star – Bearish pattern detected")
if C_ShootingStarBearish and ShootingStarInput and (("Bearish" == CandleType) or
CandleType == "Both")
var ttBearishShootingStar = "Shooting Star\nThis single day pattern can appear
during an uptrend and opens high, while it closes near its open. It trades much
higher as well. It is bearish in nature, but looks like an Inverted Hammer."
label.new(bar_index, patternLabelPosHigh, text="SS",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishShootingStar)
C_InvertedHammerBullishNumberOfCandles = 1
C_InvertedHammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor *
C_Body and not C_HasDnShadow
if C_DownTrend
C_InvertedHammerBullish := true
alertcondition(C_InvertedHammerBullish, title = "Inverted Hammer – Bullish",
message = "New Inverted Hammer – Bullish pattern detected")
if C_InvertedHammerBullish and InvertedHammerInput and (("Bullish" == CandleType)
or CandleType == "Both")

var ttBullishInvertedHammer = "Inverted Hammer\nIf in a downtrend, then the


open is lower. When it eventually trades higher, but closes near its open, it will
look like an inverted version of the Hammer Candlestick. This is a one-day bullish
reversal pattern."
label.new(bar_index, patternLabelPosLow, text="IH", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishInvertedHammer)
C_MorningStarBullishNumberOfCandles = 3
C_MorningStarBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody
if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody
and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] <
C_BodyLo
C_MorningStarBullish := true
alertcondition(C_MorningStarBullish, title = "Morning Star – Bullish", message =
"New Morning Star – Bullish pattern detected")
if C_MorningStarBullish and MorningStarInput and (("Bullish" == CandleType) or
CandleType == "Both")

var ttBullishMorningStar = "Morning Star\nA three-day bullish reversal pattern,


which consists of three candlesticks will look something like this: The first being
a long-bodied red candle that extends the current downtrend. Next comes a short,
middle candle that gaps down on the open. After comes a long-bodied green candle,
which gaps up on the open and closes above the midpoint of the body of the first
day."
label.new(bar_index, patternLabelPosLow, text="MS", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishMorningStar)
C_EveningStarBearishNumberOfCandles = 3
C_EveningStarBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody
if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody
and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] >
C_BodyHi
C_EveningStarBearish := true
alertcondition(C_EveningStarBearish, title = "Evening Star – Bearish", message =
"New Evening Star – Bearish pattern detected")
if C_EveningStarBearish and EveningStarInput and (("Bearish" == CandleType) or
CandleType == "Both")

var ttBearishEveningStar = "Evening Star\nThis candlestick pattern is bearish


and continues an uptrend with a long-bodied, green candle day. It is then followed
by a gapped and small-bodied candle day, and concludes with a downward close. The
close would be below the first day’s midpoint."
label.new(bar_index, patternLabelPosHigh, text="ES",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishEveningStar)
C_MarubozuWhiteBullishNumberOfCandles = 1
C_MarubozuShadowPercentWhite = 5.0
C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <=
C_MarubozuShadowPercentWhite/100*C_Body and C_DnShadow <=
C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody
alertcondition(C_MarubozuWhiteBullish, title = "Marubozu White – Bullish", message
= "New Marubozu White – Bullish pattern detected")
if C_MarubozuWhiteBullish and MarubozuWhiteInput and (("Bullish" == CandleType)
or CandleType == "Both")

var ttBullishMarubozuWhite = "Marubozu White\nA Marubozu White Candle is a


candlestick that does not have a shadow that extends from its candle body at either
the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.”
Other sources may call it a Bald or Shaven Head Candle."
label.new(bar_index, patternLabelPosLow, text="MW", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishMarubozuWhite)
C_MarubozuBlackBearishNumberOfCandles = 1
C_MarubozuShadowPercentBearish = 5.0
C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <=
C_MarubozuShadowPercentBearish/100*C_Body and C_DnShadow <=
C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody
alertcondition(C_MarubozuBlackBearish, title = "Marubozu Black – Bearish", message
= "New Marubozu Black – Bearish pattern detected")
if C_MarubozuBlackBearish and MarubozuBlackInput and (("Bearish" == CandleType)
or CandleType == "Both")

var ttBearishMarubozuBlack = "Marubozu Black\nThis is a candlestick that has no


shadow, which extends from the red-bodied candle at the open, the close, or even at
both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick
can also be referred to as Bald or Shaven Head."
label.new(bar_index, patternLabelPosHigh, text="MB",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishMarubozuBlack)
//C_DojiNumberOfCandles = 1
//C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body
//C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body
//alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title
= "Doji", message = "New Doji pattern detected")
//if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput
// var ttDoji = "Doji\nWhen the open and close of a security are essentially
equal to each other, a doji candle forms. The length of both upper and lower
shadows may vary, causing the candlestick you are left with to either resemble a
cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-
seller indecision in a tug-of-war of sorts. As price moves either above or below
the opening level during the session, the close is either at or near the opening
level."
// label.new(bar_index, patternLabelPosLow, text="D",
style=label.style_label_up, color = label_color_neutral,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttDoji)
C_GravestoneDojiBearishNumberOfCandles = 1
C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body
alertcondition(C_GravestoneDojiBearish, title = "Gravestone Doji – Bearish",
message = "New Gravestone Doji – Bearish pattern detected")
if C_GravestoneDojiBearish and GravestoneDojiInput and (("Bearish" == CandleType)
or CandleType == "Both")

var ttBearishGravestoneDoji = "Gravestone Doji\nWhen a doji is at or is close


to the day’s low point, a doji line will develop."
label.new(bar_index, patternLabelPosHigh, text="GD",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishGravestoneDoji)
C_DragonflyDojiBullishNumberOfCandles = 1
C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body
alertcondition(C_DragonflyDojiBullish, title = "Dragonfly Doji – Bullish", message
= "New Dragonfly Doji – Bullish pattern detected")
if C_DragonflyDojiBullish and DragonflyDojiInput and (("Bullish" == CandleType)
or CandleType == "Both")

var ttBullishDragonflyDoji = "Dragonfly Doji\nSimilar to other Doji days, this


particular Doji also regularly appears at pivotal market moments. This is a
specific Doji where both the open and close price are at the high of a given day."
label.new(bar_index, patternLabelPosLow, text="DD", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishDragonflyDoji)
C_HaramiCrossBullishNumberOfCandles = 2
C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and
C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiCrossBullish, title = "Harami Cross – Bullish", message =
"New Harami Cross – Bullish pattern detected")
if C_HaramiCrossBullish and HaramiCrossInput and (("Bullish" == CandleType) or
CandleType == "Both")

var ttBullishHaramiCross = "Harami Cross\nThis candlestick pattern is a


variation of the Harami Bullish pattern. It is found during a downtrend. The two-
day candlestick pattern consists of a Doji candle that is entirely encompassed
within the body of what was once a red-bodied candle."
label.new(bar_index, patternLabelPosLow, text="HC", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishHaramiCross)
C_HaramiCrossBearishNumberOfCandles = 2
C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and
C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiCrossBearish, title = "Harami Cross – Bearish", message =
"New Harami Cross – Bearish pattern detected")
if C_HaramiCrossBearish and HaramiCrossInput and (("Bearish" == CandleType) or
CandleType == "Both")

var ttBearishHaramiCross = "Harami Cross\nThis candlestick pattern is a


variation of the Harami Bearish pattern. It is found during an uptrend. This is a
two-day candlestick pattern with a Doji candle that is entirely encompassed within
the body that was once a green-bodied candle. The Doji shows that some indecision
has entered the minds of sellers, and the pattern hints that the trend might
reverse."
label.new(bar_index, patternLabelPosHigh, text="HC",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishHaramiCross)
C_HaramiBullishNumberOfCandles = 2
C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and
C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiBullish, title = "Harami – Bullish", message = "New Harami –
Bullish pattern detected")
if C_HaramiBullish and HaramiInput and (("Bullish" == CandleType) or CandleType
== "Both")

var ttBullishHarami = "Harami\nThis two-day candlestick pattern consists of a


small-bodied green candle that is entirely encompassed within the body of what was
once a red-bodied candle."
label.new(bar_index, patternLabelPosLow, text="BH", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishHarami)
C_HaramiBearishNumberOfCandles = 2
C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody
and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
alertcondition(C_HaramiBearish, title = "Harami – Bearish", message = "New Harami –
Bearish pattern detected")
if C_HaramiBearish and HaramiInput and (("Bearish" == CandleType) or CandleType
== "Both")

var ttBearishHarami = "Harami\nThis is a two-day candlestick pattern with a


small, red-bodied candle that is entirely encompassed within the body that was once
a green-bodied candle."
label.new(bar_index, patternLabelPosHigh, text="BH",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishHarami)
C_LongLowerShadowBullishNumberOfCandles = 1
C_LongLowerShadowPercent = 75.0
C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent
alertcondition(C_LongLowerShadowBullish, title = "Long Lower Shadow – Bullish",
message = "New Long Lower Shadow – Bullish pattern detected")
if C_LongLowerShadowBullish and LongLowerShadowInput and (("Bullish" ==
CandleType) or CandleType == "Both")

var ttBullishLongLowerShadow = "Long Lower Shadow\nTo indicate seller


domination of the first part of a session, candlesticks will present with long
lower shadows and short upper shadows, consequently lowering prices."
label.new(bar_index, patternLabelPosLow, text="LLS",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishLongLowerShadow)
C_LongUpperShadowBearishNumberOfCandles = 1
C_LongShadowPercent = 75.0
C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent
alertcondition(C_LongUpperShadowBearish, title = "Long Upper Shadow – Bearish",
message = "New Long Upper Shadow – Bearish pattern detected")
if C_LongUpperShadowBearish and LongUpperShadowInput and (("Bearish" ==
CandleType) or CandleType == "Both")

var ttBearishLongUpperShadow = "Long Upper Shadow\nTo indicate buyer domination


of the first part of a session, candlesticks will present with long upper shadows,
as well as short lower shadows, consequently raising bidding prices."
label.new(bar_index, patternLabelPosHigh, text="LUS",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishLongUpperShadow)
C_SpinningTopWhiteNumberOfCandles = 1
C_SpinningTopWhitePercent = 34.0
C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and
C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent and not C_IsDojiBody
C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody
alertcondition(C_SpinningTopWhite, title = "Spinning Top White", message = "New
Spinning Top White pattern detected")
if C_SpinningTopWhite and SpinningTopWhiteInput
var ttSpinningTopWhite = "Spinning Top White\nWhite spinning tops are
candlestick lines that are small, green-bodied, and possess shadows (upper and
lower) that end up exceeding the length of candle bodies. They often signal
indecision between buyer and seller."
label.new(bar_index, patternLabelPosLow, text="STW",
style=label.style_label_up, color = label_color_neutral,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttSpinningTopWhite)
C_SpinningTopBlackNumberOfCandles = 1
C_SpinningTopBlackPercent = 34.0
C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and
C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent and not C_IsDojiBody
C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody
alertcondition(C_SpinningTopBlack, title = "Spinning Top Black", message = "New
Spinning Top Black pattern detected")
if C_SpinningTopBlack and SpinningTopBlackInput
var ttSpinningTopBlack = "Spinning Top Black\nBlack spinning tops are
candlestick lines that are small, red-bodied, and possess shadows (upper and lower)
that end up exceeding the length of candle bodies. They often signal indecision."
label.new(bar_index, patternLabelPosLow, text="STB",
style=label.style_label_up, color = label_color_neutral,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttSpinningTopBlack)

C_ThreeshadowDn = C_DnShadow > (C_Body * 1.3) // (C_DnShadow * 0.5) > C_Body


C_ThreeshadowUp = (C_Body * 0.9) > C_UpShadow // C_Body > C_UpShadow

ThreeShadowBull = not C_ThreeshadowDn[4] and (C_ThreeshadowDn and


C_ThreeshadowDn[1] and C_ThreeshadowDn[2]) and (C_ThreeshadowUp and
C_ThreeshadowUp[1] and C_ThreeshadowUp[2])
and (close[1] >= close[2]*0.9)
// and C_NoshadowUp and C_NoshadowDn and C_NoshadowUp[1] and C_NoshadowDn[1]
and C_NoshadowUp[2] and C_NoshadowDn[2]

alertcondition(ThreeShadowBull, title = "Three Shadow Strategy – Bullish", message


= "ALrt for Three Shadow Strategy – Bullish pattern detected")
if ThreeShadowBull and ThreeShadowBullInput and ((CandleType == "Bullish") or
CandleType == "Both")
var ThreeShadowBullish = "Three Shadow Strategy\nThis bullish reversal pattern
is made up if detect in the floor."
label.new(bar_index[0], patternLabelPosLow, text="3Sh",
style=label.style_label_up, color = color.blue,
textcolor=label_ICHI_color_Text_Cross, tooltip = ThreeShadowBullish)

//C_ThreeWhiteSoldiersBullishNumberOfCandles = 3
//C_3WSld_ShadowPercent = 0.6
//C_3WSld_HaveNotUpShadow = C_Body * C_3WSld_ShadowPercent > C_UpShadow
//C_3WSld_HaveNotUpShadow = C_Range / 3 > C_UpShadow
//C_ThreeWhiteSoldiersBullish = true
//if C_Body and C_Body[1] and C_Body[2]
// if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2]
// C_ThreeWhiteSoldiersBullish := C_3WSld_HaveNotUpShadow and
C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2]
C_NoshadowUp = (C_Body * 0.9) > C_UpShadow
C_NoshadowDn = (C_Body * 0.9) > C_DnShadow
tws = (not C_WhiteBody[3] and C_WhiteBody[2] and C_WhiteBody[1] and C_WhiteBody)
and (C_Body[1]>C_Body[2])
and (C_Body[2] <= C_Body[1]*0.9) and (C_Body[2] >= C_Body[1]*0.65)
and C_NoshadowUp and C_NoshadowDn and C_NoshadowUp[1] and C_NoshadowDn[1]
and C_NoshadowUp[2] and C_NoshadowDn[2]

alertcondition(tws, title = "Three White Soldiers – Bullish", message = "New Three


White Soldiers – Bullish pattern detected")
if tws and ThreeWhiteSoldiersInput and ((CandleType == "Bullish") or CandleType
== "Both")
var ttBullishThreeWhiteSoldiers = "Three White Soldiers\nThis bullish reversal
pattern is made up of three long-bodied, green candles in immediate succession.
Each one opens within the body before it and the close is near to the daily high."
label.new(bar_index[0], patternLabelPosLow, text="3WS",
style=label.style_label_up, color = label_color_bullish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBullishThreeWhiteSoldiers)

C_ThreeBlackCrowsBearishNumberOfCandles = 3
C_3BCrw_ShadowPercent = 5.0
C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow
C_ThreeBlackCrowsBearish = false
if C_LongBody and C_LongBody[1] and C_LongBody[2]
if C_BlackBody and C_BlackBody[1] and C_BlackBody[2]
C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and
open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and
C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and
C_3BCrw_HaveNotDnShadow[2]
alertcondition(C_ThreeBlackCrowsBearish, title = "Three Black Crows – Bearish",
message = "New Three Black Crows – Bearish pattern detected")
if C_ThreeBlackCrowsBearish and ThreeBlackCrowsInput and (("Bearish" ==
CandleType) or CandleType == "Both")

var ttBearishThreeBlackCrows = "Three Black Crows\nThis is a bearish reversal


pattern that consists of three long, red-bodied candles in immediate succession.
For each of these candles, each day opens within the body of the day before and
closes either at or near its low."
label.new(bar_index, patternLabelPosHigh, text="3BC",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishThreeBlackCrows)
C_EngulfingBullishNumberOfCandles = 2
C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1]
and C_SmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1]
or open < close[1] )
alertcondition(C_EngulfingBullish, title = "Engulfing – Bullish", message = "New
Engulfing – Bullish pattern detected")
if C_EngulfingBullish and EngulfingInput and (("Bullish" == CandleType) or
CandleType == "Both")

var ttBullishEngulfing = "Engulfing\nAt the end of a given downward trend,


there will most likely be a reversal pattern. To distinguish the first day, this
candlestick pattern uses a small body, followed by a day where the candle body
fully overtakes the body from the day before, and closes in the trend’s opposite
direction. Although similar to the outside reversal chart pattern, it is not
essential for this pattern to completely overtake the range (high to low), rather
only the open and the close."
label.new(bar_index, patternLabelPosLow, text="BE", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishEngulfing)
C_EngulfingBearishNumberOfCandles = 2
C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1]
and C_SmallBody[1] and close <= open[1] and open >= close[1] and ( close < open[1]
or open > close[1] )
alertcondition(C_EngulfingBearish, title = "Engulfing – Bearish", message = "New
Engulfing – Bearish pattern detected")
if C_EngulfingBearish and EngulfingInput and (("Bearish" == CandleType) or
CandleType == "Both")

var ttBearishEngulfing = "Engulfing\nAt the end of a given uptrend, a reversal


pattern will most likely appear. During the first day, this candlestick pattern
uses a small body. It is then followed by a day where the candle body fully
overtakes the body from the day before it and closes in the trend’s opposite
direction. Although similar to the outside reversal chart pattern, it is not
essential for this pattern to fully overtake the range (high to low), rather only
the open and the close."
label.new(bar_index, patternLabelPosHigh, text="BE",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishEngulfing)
C_AbandonedBabyBullishNumberOfCandles = 3
C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and
low[2] > high[1] and C_WhiteBody and high[1] < low
alertcondition(C_AbandonedBabyBullish, title = "Abandoned Baby – Bullish", message
= "New Abandoned Baby – Bullish pattern detected")
if C_AbandonedBabyBullish and AbandonedBabyInput and (("Bullish" == CandleType)
or CandleType == "Both")

var ttBullishAbandonedBaby = "Abandoned Baby\nThis candlestick pattern is quite


rare as far as reversal patterns go. The first of the pattern is a large down
candle. Next comes a doji candle that gaps below the candle before it. The doji
candle is then followed by another candle that opens even higher and swiftly moves
to the upside."
label.new(bar_index, patternLabelPosLow, text="AB", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishAbandonedBaby)
C_AbandonedBabyBearishNumberOfCandles = 3
C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and
high[2] < low[1] and C_BlackBody and low[1] > high
alertcondition(C_AbandonedBabyBearish, title = "Abandoned Baby – Bearish", message
= "New Abandoned Baby – Bearish pattern detected")
if C_AbandonedBabyBearish and AbandonedBabyInput and (("Bearish" == CandleType)
or CandleType == "Both")

var ttBearishAbandonedBaby = "Abandoned Baby\nA bearish abandoned baby is a


specific candlestick pattern that often signals a downward reversal trend in terms
of security price. It is formed when a gap appears between the lowest price of a
doji-like candle and the candlestick of the day before. The earlier candlestick is
green, tall, and has small shadows. The doji candle is also tailed by a gap between
its lowest price point and the highest price point of the candle that comes next,
which is red, tall and also has small shadows. The doji candle shadows must
completely gap either below or above the shadows of the first and third day in
order to have the abandoned baby pattern effect."
label.new(bar_index, patternLabelPosHigh, text="AB",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishAbandonedBaby)
C_TriStarBullishNumberOfCandles = 3
C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo
C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi
C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and
C_BodyGapUpBullish
alertcondition(C_TriStarBullish, title = "Tri-Star – Bullish", message = "New Tri-
Star – Bullish pattern detected")
if C_TriStarBullish and TriStarInput and (("Bullish" == CandleType) or CandleType
== "Both")

var ttBullishTriStar = "Tri-Star\nA bullish TriStar candlestick pattern can


form when three doji candlesticks materialize in immediate succession at the tail-
end of an extended downtrend. The first doji candle marks indecision between bull
and bear. The second doji gaps in the direction of the leading trend. The third
changes the attitude of the market once the candlestick opens in the direction
opposite to the trend. Each doji candle has a shadow, all comparatively shallow,
which signify an interim cutback in volatility."
label.new(bar_index, patternLabelPosLow, text="3S", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishTriStar)
C_TriStarBearishNumberOfCandles = 3
C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUp = C_BodyHi[1] < C_BodyLo
C_BodyGapDn = C_BodyLo[1] > C_BodyHi
C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn
alertcondition(C_TriStarBearish, title = "Tri-Star – Bearish", message = "New Tri-
Star – Bearish pattern detected")
if C_TriStarBearish and TriStarInput and (("Bearish" == CandleType) or CandleType
== "Both")

var ttBearishTriStar = "Tri-Star\nThis particular pattern can form when three


doji candlesticks appear in immediate succession at the end of an extended uptrend.
The first doji candle marks indecision between bull and bear. The second doji gaps
in the direction of the leading trend. The third changes the attitude of the market
once the candlestick opens in the direction opposite to the trend. Each doji candle
has a shadow, all comparatively shallow, which signify an interim cutback in
volatility."
label.new(bar_index, patternLabelPosHigh, text="3S",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishTriStar)
C_KickingBullishNumberOfCandles = 2
C_MarubozuShadowPercent = 5.0
C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and
C_DnShadow <= C_MarubozuShadowPercent/100*C_Body
C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody
C_MarubozuBlackBullish = C_Marubozu and C_BlackBody
C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and
high[1] < low
alertcondition(C_KickingBullish, title = "Kicking – Bullish", message = "New
Kicking – Bullish pattern detected")
if C_KickingBullish and KickingInput and (("Bullish" == CandleType) or CandleType
== "Both")

var ttBullishKicking = "Kicking\nThe first day candlestick is a bearish


marubozu candlestick with next to no upper or lower shadow and where the price
opens at the day’s high and closes at the day’s low. The second day is a bullish
marubozu pattern, with next to no upper or lower shadow and where the price opens
at the day’s low and closes at the day’s high. Additionally, the second day gaps up
extensively and opens above the opening price of the day before. This gap or
window, as the Japanese call it, lies between day one and day two’s bullish
candlesticks."
label.new(bar_index, patternLabelPosLow, text="K", style=label.style_label_up,
color = label_color_bullish, textcolor=label_ICHI_color_Text_Cross, tooltip =
ttBullishKicking)
C_KickingBearishNumberOfCandles = 2
C_MarubozuBullishShadowPercent = 5.0
C_MarubozuBearishKicking = C_LongBody and C_UpShadow <=
C_MarubozuBullishShadowPercent/100*C_Body and C_DnShadow <=
C_MarubozuBullishShadowPercent/100*C_Body
C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody
C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody
C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and
low[1] > high
alertcondition(C_KickingBearish, title = "Kicking – Bearish", message = "New
Kicking – Bearish pattern detected")
if C_KickingBearish and KickingInput and (("Bearish" == CandleType) or CandleType
== "Both")

var ttBearishKicking = "Kicking\nA bearish kicking pattern will occur,


subsequently signaling a reversal for a new downtrend. The first day candlestick is
a bullish marubozu. The second day gaps down extensively and opens below the
opening price of the day before. There is a gap between day one and two’s bearish
candlesticks."
label.new(bar_index, patternLabelPosHigh, text="K",
style=label.style_label_down, color = label_color_bearish,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttBearishKicking)
var ttAllCandlestickPatterns = "All Candlestick Patterns\n"
label.new(bar_index, patternLabelPosLow, text="Collection",
style=label.style_label_up, color = label_color_neutral,
textcolor=label_ICHI_color_Text_Cross, tooltip = ttAllCandlestickPatterns)

//////////////////////////////////////////////////////////////////////

You might also like