Indicator · Pine Script v5 · On the chart

Bull & Bear Engulfing - 3 Strike and 180 Candles X EMA

by msongkiet· code credited to SenatorVonShaft

This indicator detects bullish and bearish engulfing candlestick patterns on the main price chart based on configurable bar fullness and height filters.

View on GitHub

GitHub stars16on the repository
Pine versionv5runs as is
Lines of code45
Settings12inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago31 Aug 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

45 lines of Pine Script v5 from Bull & Bear Engulfing - 3 Strike and 180 Candles X EMA.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Bull & Bear Engulfing - 3 Strike and 180 Candles X EMA.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SenatorVonShaft

//@version=5
indicator("Bull & Bear Engulfing - 3 Strike and 180 Candles X EMA" , overlay = true)

candlperc = input.float(title="Bar Fullness Percentage",minval=50.00, maxval=100, step=0.1, defval=80) * 0.01
AvgBarBack = input.int(title = "Average Bar Backwds Candles", minval=1, step=1, defval=20)
avgcandlmult = input.float(title="Average Bar Height Multiptier", minval=0.1, maxval=20, step=0.1, defval=1.5)

ortBar = ta.sma(math.abs(close - open) , AvgBarBack)
ortBarCond = math.abs(close - open) > avgcandlmult * ortBar
BiggerBar = math.abs (close - open) > math.abs (close [1] - open [1])
BullBar = close > open and hl2 > open and ((close - open) / (high - low)) >= candlperc and BiggerBar and ortBarCond
BearBar = close < open and hl2 < open and ((open - close) / (high - low)) >= candlperc and BiggerBar and ortBarCond
Bull3 = BullBar and close[1] < open [1] and close[2] < open [2] and close[3] < open [3] and close > open [3]
Bear3 = BearBar and close[1] > open [1] and close[2] > open [2] and close[3] > open [3] and close < open [3]
Bull180 = BearBar[1] and close > open and math.abs(open - close) > math.abs(open[1] - close [1])
Bear180 = BullBar[1] and close < open and math.abs(open - close) > math.abs(open[1] - close [1])

plotshape(BullBar,  style=shape.labelup , location= location.belowbar, color = color.rgb(76, 175, 79, 10))
plotshape(BearBar,  style=shape.labeldown, location=location.abovebar , color = color.rgb(255, 82, 82, 10))
plotshape(Bull3,  style=shape.labelup , location=location.belowbar, color = color.rgb(76, 175, 79, 10), text = "3S" , textcolor = color.white )
plotshape(Bear3,  style=shape.labeldown , location=location.abovebar , color = color.rgb(255, 82, 82, 10) , text = "3S" , textcolor = color.white  )
plotshape(Bull180,  style=shape.labelup , location=location.belowbar, color = color.rgb(76, 175, 79, 10) , text = "180" , textcolor = color.white  )
plotshape(Bear180,  style=shape.labeldown , location=location.abovebar , color = color.rgb(255, 82, 82, 10) , text = "180" , textcolor = color.white  )
plot (ortBar , color = color.white)

len1 = input.int(9, minval=1, title="Length1")
src1 = input(close, title="Source1")
offset1 = input.int(title="Offset1", defval=0, minval=-500, maxval=500)
out1 = ta.ema(src1, len1)
plot(out1, title="EMA1", color=color.blue, offset=offset1)

len2 = input.int(20, minval=1, title="Length2")
src2 = input(close, title="Source2")
offset2 = input.int(title="Offset2", defval=0, minval=-500, maxval=500)
out2 = ta.ema(src2, len2)
plot(out2, title="EMA2", color=color.rgb(243, 33, 233), offset=offset2)

len3 = input.int(50, minval=1, title="Length3")
src3 = input(close, title="Source3")
offset3 = input.int(title="Offset3", defval=0, minval=-500, maxval=500)
out3 = ta.ema(src3, len3)
plot(out3, title="EMA3", color=color.rgb(243, 75, 33), offset=offset3)

Overview

Bull & Bear Engulfing - 3 Strike and 180 Candles X EMA identifies specific pattern variations, including 3-Strike reversals and 180-degree turnarounds, marking them with visual shape labels directly above or below the price candles. Additionally, it plots three customizable Exponential Moving Averages (EMAs) with independent length and offset settings to help traders assess prevailing market trends alongside pattern signals.

Details

Published by

msongkiet on GitHub

Code credit

SenatorVonShaft, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Bar Fullness Percentagefloat80candlperc
Average Bar Backwds Candlesint20AvgBarBack
Average Bar Height Multiptierfloat1.5avgcandlmult
Length1int9len1
Source1sourceclosesrc1
Offset1int0offset1
Length2int20len2
Source2sourceclosesrc2
Offset2int0offset2
Length3int50len3
Source3sourceclosesrc3
Offset3int0offset3
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

Smoothed candles

by be-thomas
65 stars

This indicator draws smoothed candlesticks on the price chart. It applies a simple moving average of a user-set length, defaulting to nine, separately to open, high, low, and close, then plots those four values with plotcandle. Wick color is green when the raw

Indicator v5 Moving averagesCandlestick patterns
Updated 4 days ago · GPL-3.0 GitHub repository of Smoothed candles

Major Buy Setup

by dcaoyuan
55 stars

Major Buy Setup plots a 20-period and a 50-period simple moving average on the price chart. It marks a buy when the current bar is both a bullish engulfing candle and a bald bull candle, defined as a green candle whose upper shadow is no more than five percent

Indicator v5 Moving averagesCandlestick patterns Repaints
Updated 6 months ago · Apache-2.0 GitHub repository of Major Buy Setup

30 min Pivot

by ChartsLector
41 stars

30 min Pivot is an overlay indicator that plots an exponential moving average (EMA) calculated from a specified timeframe (default 30 minutes) and flags specific multi-bar candle setups. It checks the relative distance between price and the higher-timeframe EM

Indicator v5 Moving averagesCandlestick patterns
Updated 2 days ago · None stated GitHub repository of 30 min Pivot

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers