//@version=4
study("Trend Lines by Hassan x here", overlay=true, max_bars_back = 4000)
startyear = input(defval = 2020, title = "Start Year")
startmonth = input(defval = 1, title = "Start Month")
startday = input(defval = 1, title = "Start day")
prd = input(defval = 20, title="Pivot Period", minval = 10, maxval = 50)
PPnum = input(defval = 3, title="Number of Pivot Points to check", minval = 2,
maxval = 6)
utcol = input(defval = color.lime, title = "Colors", inline = "tcol")
dtcol = input(defval = color.red, title = "", inline = "tcol")
float ph = pivothigh(prd, prd)
float pl = pivotlow(prd, prd)
var tval = array.new_float(PPnum)
var tpos = array.new_int(PPnum)
var bval = array.new_float(PPnum)
var bpos = array.new_int(PPnum)
add_to_array(apointer1, apointer2, val)=>
array.unshift(apointer1, val)
array.unshift(apointer2, bar_index)
array.pop(apointer1)
array.pop(apointer2)
if ph
add_to_array(tval, tpos, ph)
if pl
add_to_array(bval, bpos, pl)
// line definitions
maxline = 3
var bln = array.new_line(maxline, na)
var tln = array.new_line(maxline, na)
// loop for pivot points to check if there is possible trend line
countlinelo = 0
countlinehi = 0
starttime = timestamp(startyear, startmonth, startday, 0, 0, 0)
if time >= starttime
for x = 0 to maxline - 1
line.delete(array.get(bln, x))
line.delete(array.get(tln, x))
for p1 = 0 to PPnum - 2
uv1 = 0.0
uv2 = 0.0
up1 = 0
up2 = 0
if countlinelo <= maxline
for p2 = PPnum - 1 to p1 + 1
val1 = array.get(bval, p1)
val2 = array.get(bval, p2)
pos1 = array.get(bpos, p1)
pos2 = array.get(bpos, p2)
if val1 > val2
diff = (val1 - val2) / (pos1 - pos2)
hline = val2 + diff
lloc = bar_index
lval = low
valid = true
for x = pos2 + 1 - prd to bar_index
if close[bar_index - x] < hline
valid := false
break
lloc := x
lval := hline
hline := hline + diff
if valid
uv1 := hline - diff
uv2 := val2
up1 := lloc
up2 := pos2
break
dv1 = 0.0
dv2 = 0.0
dp1 = 0
dp2 = 0
if countlinehi <= maxline
for p2 = PPnum - 1 to p1 + 1
val1 = array.get(tval, p1)
val2 = array.get(tval, p2)
pos1 = array.get(tpos, p1)
pos2 = array.get(tpos, p2)
if val1 < val2
diff = (val2 - val1) / float(pos1 - pos2)
hline = val2 - diff
lloc = bar_index
lval = high
valid = true
for x = pos2 + 1 - prd to bar_index
if close[bar_index - x] > hline
valid := false
break
lloc := x
lval := hline
hline := hline - diff
if valid
dv1 := hline + diff
dv2 := val2
dp1 := lloc
dp2 := pos2
break
// if there is continues uptrend line then draw it
if up1 != 0 and up2 != 0 and countlinelo < maxline
countlinelo += 1
array.set(bln, countlinelo - 1, line.new(up2 - prd, uv2, up1, uv1,
color = utcol))
// if there is continues downtrend line then draw it
if dp1 != 0 and dp2 != 0 and countlinehi < maxline
countlinehi += 1
array.set(tln, countlinehi - 1, line.new(dp2 - prd, dv2, dp1, dv1,
color = dtcol))
C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = input(trendRule1, "Detect Trend Based On", options=[trendRule1,
trendRule2, "No detection"])
if trendRule == trendRule1
priceAvg = sma(close, 50)
C_DownTrend := close < priceAvg
C_UpTrend := close > priceAvg
if trendRule == trendRule2
sma200 = sma(close, 200)
sma50 = sma(close, 50)
C_DownTrend := close < sma50 and sma50 < sma200
C_UpTrend := close > sma50 and sma50 > sma200
C_Len = 14 // 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)
CandleType = input(title = "Pattern Type", defval="Both", options=["Bullish",
"Bearish", "Both"])
AbandonedBabyInput = input(title = "Abandoned Baby" ,defval=true)
DarkCloudCoverInput = input(title = "Dark Cloud Cover" ,defval=false)
DojiInput = input(title = "Doji" ,defval=true)
DojiStarInput = input(title = "Doji Star" ,defval=false)
DownsideTasukiGapInput = input(title = "Downside Tasuki Gap" ,defval=false)
DragonflyDojiInput = input(title = "Dragonfly Doji" ,defval=true)
EngulfingInput = input(title = "Engulfing" ,defval=true)
EveningDojiStarInput = input(title = "Evening Doji Star" ,defval=false)
EveningStarInput = input(title = "Evening Star" ,defval=false)
FallingThreeMethodsInput = input(title = "Falling Three Methods" ,defval=false)
FallingWindowInput = input(title = "Falling Window" ,defval=false)
GravestoneDojiInput = input(title = "Gravestone Doji" ,defval=false)
HammerInput = input(title = "Hammer" ,defval=true)
HangingManInput = input(title = "Hanging Man" ,defval=false)
HaramiCrossInput = input(title = "Harami Cross" ,defval=false)
HaramiInput = input(title = "Harami" ,defval=false)
InvertedHammerInput = input(title = "Inverted Hammer" ,defval=false)
KickingInput = input(title = "Kicking" ,defval=false)
LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=false)
LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=false)
MarubozuBlackInput = input(title = "Marubozu Black" ,defval=false)
MarubozuWhiteInput = input(title = "Marubozu White" ,defval=false)
MorningDojiStarInput = input(title = "Morning Doji Star" ,defval=false)
MorningStarInput = input(title = "Morning Star" ,defval=false)
OnNeckInput = input(title = "On Neck" ,defval=false)
PiercingInput = input(title = "Piercing" ,defval=false)
RisingThreeMethodsInput = input(title = "Rising Three Methods" ,defval=false)
RisingWindowInput = input(title = "Rising Window" ,defval=false)
ShootingStarInput = input(title = "Shooting Star" ,defval=false)
SpinningTopBlackInput = input(title = "Spinning Top Black" ,defval=false)
SpinningTopWhiteInput = input(title = "Spinning Top White" ,defval=false)
ThreeBlackCrowsInput = input(title = "Three Black Crows" ,defval=false)
ThreeWhiteSoldiersInput = input(title = "Three White Soldiers" ,defval=false)
TriStarInput = input(title = "Tri-Star" ,defval=false)
TweezerBottomInput = input(title = "Tweezer Bottom" ,defval=false)
TweezerTopInput = input(title = "Tweezer Top" ,defval=false)
UpsideTasukiGapInput = input(title = "Upside Tasuki Gap" ,defval=false)
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", 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 = color.red, textcolor=color.white, 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", 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 = color.blue, textcolor=color.white, 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", 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 = color.red, textcolor=color.white, 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",
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 = color.red, textcolor=color.white, 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",
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 = color.blue, textcolor=color.white, 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]
C_TweezerTopBearish := true
// alertcondition(C_TweezerTopBearish, title = "Tweezer Top", 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 = color.red, textcolor=color.white, tooltip =
ttBearishTweezerTop)
C_TweezerBottomBullishNumberOfCandles = 2
C_TweezerBottomBullish = false
if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and
abs(low-low[1]) <= C_BodyAvg*0.05 and C_BlackBody[1] and C_WhiteBody and
C_LongBody[1]
C_TweezerBottomBullish := true
// alertcondition(C_TweezerBottomBullish, title = "Tweezer Bottom", 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 = color.blue, textcolor=color.white, 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", 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 = color.red, textcolor=color.white, 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",
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 = color.red, textcolor=color.white, 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", 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 = color.blue, textcolor=color.white, 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", 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 = color.red, textcolor=color.white, 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", 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 = color.red, textcolor=color.white, 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", 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 = color.blue, textcolor=color.white, 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", 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 patte
ma_type1 = input(title="MA Type 1", type=input.string, options=["SMA", "EMA"],
defval="SMA", group="Moving Average 1")
ma_type2 = input(title="MA Type 2", type=input.string, options=["SMA", "EMA"],
defval="EMA", group="Moving Average 2")
ma_source1 = input(title="MA Source 1", type=input.source, defval=close,
group="Moving Average 1")
ma_source2 = input(title="MA Source 2", type=input.source, defval=close,
group="Moving Average 2")
ma_period1 = input(title="MA Period 1", type=input.integer, defval=14,
group="Moving Average 1")
ma_period2 = input(title="MA Period 2", type=input.integer, defval=21,
group="Moving Average 2")
ma1 = ma_type1 == "SMA" ? sma(ma_source1, ma_period1) : ema(ma_source1, ma_period1)
ma2 = ma_type2 == "SMA" ? sma(ma_source2, ma_period2) : ema(ma_source2, ma_period2)
plot(ma1, color=color.blue, title="MA 1")
plot(ma2, color=color.red, title="MA 2")
plotshape(series=close > ma1 and close > ma2 ? close : na, color=color.green,
style=shape.triangleup, location=location.abovebar, size=size.small)
plotshape(series=close < ma1 or close < ma2 ? close : na, color=color.red,
style=shape.triangledown, location=location.abovebar, size=size.small)