1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
62 lines of Pine Script v6 from indicators/Zen-CTMC/zen-ctmc-v1.1.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.
zen-ctmc-v1.1.txt
//@version=6
indicator("Zen EMA Pullback Patterns v1.1 · 20260923", shorttitle="Zen EMA PB", overlay=true)
// ── Inputs ─────────────────────────────────────────────
emaLen = input.int(20, "EMA length", minval=1)
emaSrc = input.source(close, "EMA source")
fullMC = input.bool(false, "Full micro channel (bear: lower lows too / bull: higher highs too)")
everyBar = input.bool(false, "Mark every bar that completes a pattern (off = first bar only)")
showEma = input.bool(true, "Show EMA")
showLabels = input.bool(false, "Show labels")
colorBars = input.bool(true, "Colour signal bar (bear pattern = red, bull pattern = green)")
// ── Core ───────────────────────────────────────────────
ema = ta.ema(emaSrc, emaLen)
bear = close < open // doji (close == open) is neutral and breaks the run
bull = close > open
above = close > ema
below = close < ema
// ── 3-bar pattern: 3 bear bars, all 3 closes above EMA / 3 bull bars, all 3 closes below EMA
bear3 = bear and bear[1] and bear[2] and above and above[1] and above[2]
bull3 = bull and bull[1] and bull[2] and below and below[1] and below[2]
// ── 4-bar micro channel: 3 lower highs, all 4 closes above EMA / 3 higher lows, all 4 closes below EMA
lowerHighs = high < high[1] and high[1] < high[2] and high[2] < high[3]
lowerLows = low < low[1] and low[1] < low[2] and low[2] < low[3]
higherLows = low > low[1] and low[1] > low[2] and low[2] > low[3]
higherHighs = high > high[1] and high[1] > high[2] and high[2] > high[3]
above4 = above and above[1] and above[2] and above[3]
below4 = below and below[1] and below[2] and below[3]
bearMC = lowerHighs and (not fullMC or lowerLows) and above4
bullMC = higherLows and (not fullMC or higherHighs) and below4
// ── First-bar-only filter, confirmed bars only
fire(c) => (everyBar ? c : c and not c[1]) and barstate.isconfirmed
sBear3 = fire(bear3)
sBull3 = fire(bull3)
sBearMC = fire(bearMC)
sBullMC = fire(bullMC)
// ── Plots (split so shapes never overlap on the same bar)
plot(showEma ? ema : na, "EMA", color=color.new(color.blue, 0), linewidth=2)
// Signal bar colour: bar 3 of the 3-bar pattern, bar 4 of the micro channel
bearSig = sBear3 or sBearMC
bullSig = sBull3 or sBullMC
barcolor(colorBars and bearSig ? color.red : colorBars and bullSig ? color.green : na, title="Signal bar colour")
plotshape(showLabels and sBear3 and not sBearMC, "Bear 3 above EMA", shape.triangledown, location.abovebar, color.new(color.red, 0), text="3", textcolor=color.red, size=size.small)
plotshape(showLabels and sBearMC and not sBear3, "Bear MC above EMA", shape.triangledown, location.abovebar, color.new(color.orange, 0), text="MC", textcolor=color.orange, size=size.small)
plotshape(showLabels and sBear3 and sBearMC, "Bear 3 + MC", shape.triangledown, location.abovebar, color.new(color.maroon, 0), text="3+MC", textcolor=color.maroon, size=size.small)
plotshape(showLabels and sBull3 and not sBullMC, "Bull 3 below EMA", shape.triangleup, location.belowbar, color.new(color.green, 0), text="3", textcolor=color.green, size=size.small)
plotshape(showLabels and sBullMC and not sBull3, "Bull MC below EMA", shape.triangleup, location.belowbar, color.new(color.teal, 0), text="MC", textcolor=color.teal, size=size.small)
plotshape(showLabels and sBull3 and sBullMC, "Bull 3 + MC", shape.triangleup, location.belowbar, color.new(color.olive, 0), text="3+MC", textcolor=color.olive, size=size.small)
// ── Alerts
alertcondition(sBear3, "Bear 3 above EMA", "3 bear bars closed above the EMA")
alertcondition(sBull3, "Bull 3 below EMA", "3 bull bars closed below the EMA")
alertcondition(sBearMC, "Bear MC above EMA", "Bear micro channel above the EMA")
alertcondition(sBullMC, "Bull MC below EMA", "Bull micro channel below the EMA")
Overview
Zen EMA Pullback Patterns detects 3-bar pullbacks consisting of three consecutive bearish bars above the EMA or bullish bars below it, as well as 4-bar micro channels defined by sequential lower highs or higher lows. The script plots the EMA baseline, colors signal bars upon pattern completion, and displays optional labels. Settings allow customization of EMA parameters, full micro channel requirements, and filtering between initial trigger bars or all completing bars.
3-bar EMA pullback pattern detection
4-bar micro channel pattern identification
Signal bar coloring for bullish and bearish setups
Customizable Exponential Moving Average source and length
Optional shape markers and labels on chart overlay
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
EMA length
int
20
emaLen
EMA source
source
close
emaSrc
Full micro channel (bear: lower lows too / bull: higher highs too)
bool
false
fullMC
Mark every bar that completes a pattern (off = first bar only)
bool
false
everyBar
Show EMA
bool
true
showEma
Show labels
bool
false
showLabels
Colour signal bar (bear pattern = red, bull pattern = green)
bool
true
colorBars
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.
This indicator identifies candlestick patterns on the price chart by combining price action with momentum factors and trend filters. It calculates one of four selectable oscillators: Karobein Oscillator, Money Flow Index, RSI, or Stochastic, alongside trend ru
This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th
This overlay indicator marks a bearish hanging man candlestick on the price chart. It looks for a small real body sitting in the upper part of the range, a lower shadow at least twice the body, and no upper shadow, and only while an uptrend filter is active. T
This indicator plots Bollinger Bands and smoothed HAMA candles on the price chart. It builds each candle from separate moving averages of open, high, low and close, using selectable EMA, SMA or WMA lengths. A simple moving average forms the band basis, and an
Calculates adaptive arithmetic candles by blending price data with Kaufman Efficiency Ratio smoothing and a linear regression anchor. It measures trend health using a zero-to-hundred Quality Score derived from market efficiency, regression slope, and normalize
This indicator plots 20-period and 200-period Simple Moving Averages on the main price chart while requesting multi-timeframe state data from a higher timeframe. It measures the percentage distance and slope between the two moving averages to detect narrow, pa