Skip to main content

Intermediate Strategy Patterns

Pullback strategy, channel breakout strategy, follow-the-bear strategy, and Bollinger Band strategy: complete implementations.

EMA Pullback Strategy

Pullback strategies are the bread and butter of trend-following. Rather than chasing breakouts, you wait for price to retrace to a key level within an established trend, then enter in the direction of the trend. The logic: in an uptrend (price above 50 EMA, 50 EMA above 200 EMA), wait for price to pull back to the 21 EMA, then buy when it bounces. On BTC and ETH during trending phases, pullbacks to the 21 EMA on the 4H chart are consistently tradeable.

pine-EMA pullback in trending market
1//@version=5
2strategy("EMA Pullback", overlay=true,
3 initial_capital=10000,
4 default_qty_type=strategy.percent_of_equity,
5 default_qty_value=95,
6 commission_value=0.075, slippage=2)
7
8// === INPUTS ===
9emaFast = input.int(21, "Pullback EMA")
10emaMed = input.int(50, "Trend EMA")
11emaSlow = input.int(200, "Major Trend EMA")
12atrMult = input.float(1.5, "ATR Stop Multiplier")
13tpMult = input.float(3.0, "ATR Take-Profit Multiplier")
14
15// === CALCULATIONS ===
16fast = ta.ema(close, emaFast)
17med = ta.ema(close, emaMed)
18slow = ta.ema(close, emaSlow)
19atr = ta.atr(14)
20
21// === TREND DEFINITION ===
22upTrend = med > slow and close > slow
23downTrend = med < slow and close < slow
24
25// === PULLBACK DETECTION ===
26// Price touched or crossed below the fast EMA, then bounced back above
27pulledBack = low <= fast and close > fast
28bullPullback = upTrend and pulledBack and close > open
29
30// === EXECUTION ===
31if bullPullback
32 strategy.entry("PB Long", strategy.long)
33 strategy.exit("PB TP/SL", "PB Long",
34 limit = close + atr * tpMult,
35 stop = close - atr * atrMult)
36
37// Trend reversal exit
38if ta.crossunder(med, slow)
39 strategy.close_all(comment="Trend reversal")
40
41// === VISUALS ===
42plot(fast, "21 EMA", color.new(color.blue, 0), 1)
43plot(med, "50 EMA", color.new(color.orange, 0), 2)
44plot(slow, "200 EMA", color.new(color.white, 30), 2)
45bgcolor(bullPullback ? color.new(color.green, 90) : na)

Why pullbacks outperform breakouts in crypto

Crypto markets are dominated by liquidation cascades and stop hunts. Breakout traders frequently get caught by false breakouts: price pushes above resistance, triggers breakout longs, then reverses and liquidates them. Pullback traders avoid this by entering after the initial move has been confirmed and price returns to a logical level. The trade-off is that you miss the first part of the move, but your win rate is significantly higher.

Donchian Channel Breakout Strategy

The Donchian Channel plots the highest high and lowest low over N periods. The classic "Turtle Traders" strategy enters long when price breaks above the 20-day high and exits when price breaks below the 10-day low. Adding a trailing exit instead of a fixed channel exit significantly improves performance on trending assets like BTC.

pine-Donchian channel breakout with trailing exit
1//@version=5
2strategy("Donchian Breakout", overlay=true,
3 initial_capital=10000,
4 default_qty_type=strategy.percent_of_equity,
5 default_qty_value=95,
6 commission_value=0.075, slippage=2)
7
8entryLen = input.int(20, "Entry Channel Length", minval=5)
9exitLen = input.int(10, "Exit Channel Length", minval=3)
10atrLen = input.int(14, "ATR Length")
11atrMult = input.float(3.0, "ATR Trailing Multiplier")
12
13// === CHANNELS ===
14entryHigh = ta.highest(high, entryLen)[1] // Previous bar's channel
15entryLow = ta.lowest(low, entryLen)[1]
16exitLow = ta.lowest(low, exitLen)[1]
17exitHigh = ta.highest(high, exitLen)[1]
18atr = ta.atr(atrLen)
19
20// === ENTRIES ===
21if close > entryHigh
22 strategy.entry("DC Long", strategy.long)
23
24if close < entryLow
25 strategy.entry("DC Short", strategy.short)
26
27// === EXITS ===
28// Channel exit for longs: close below exit channel low
29if strategy.position_size > 0 and close < exitLow
30 strategy.close("DC Long", comment="Channel exit")
31
32// Channel exit for shorts: close above exit channel high
33if strategy.position_size < 0 and close > exitHigh
34 strategy.close("DC Short", comment="Channel exit")
35
36// ATR trailing stop as additional protection
37if strategy.position_size > 0
38 strategy.exit("Trail Long", "DC Long",
39 trail_points=atr*atrMult/syminfo.mintick,
40 trail_offset=atr*1.5/syminfo.mintick)
41
42// === VISUALS ===
43upperBand = plot(entryHigh, "Entry High", color.new(color.green, 40))
44lowerBand = plot(entryLow, "Entry Low", color.new(color.red, 40))
45fill(upperBand, lowerBand, color=color.new(color.blue, 95))

Follow-the-Bear: Counter-Trend Exhaustion

The Follow-the-Bear strategy fades extreme moves after exhaustion signals. The idea: when price has moved too far too fast (measured by distance from a moving average and RSI extremes), a snap-back is likely. This is a mean-reversion approach that works well during choppy, range-bound periods, which describe crypto markets roughly 70% of the time.

pine-Counter-trend exhaustion fading
1//@version=5
2strategy("Follow the Bear", overlay=true,
3 initial_capital=10000,
4 default_qty_type=strategy.percent_of_equity,
5 default_qty_value=90,
6 commission_value=0.075, slippage=2)
7
8emaLen = input.int(21, "EMA Length")
9rsiLen = input.int(7, "RSI Length")
10distPct = input.float(5.0, "Distance from EMA (%)", step=0.5)
11rsiExOB = input.int(80, "RSI Exhaustion OB")
12rsiExOS = input.int(20, "RSI Exhaustion OS")
13atrMult = input.float(1.5, "ATR Stop Mult")
14
15ema = ta.ema(close, emaLen)
16rsi = ta.rsi(close, rsiLen)
17atr = ta.atr(14)
18distPctCalc = (close - ema) / ema * 100
19
20// Bearish exhaustion: price far above EMA + RSI overbought
21bearExhaustion = distPctCalc > distPct and rsi > rsiExOB and
22 close < open // Bearish candle confirms reversal starting
23
24// Bullish exhaustion: price far below EMA + RSI oversold
25bullExhaustion = distPctCalc < -distPct and rsi < rsiExOS and
26 close > open // Bullish candle confirms reversal starting
27
28if bullExhaustion
29 strategy.entry("Fade Short", strategy.long)
30 strategy.exit("Fade SL", "Fade Short",
31 limit = ema,
32 stop = close - atr * atrMult)
33
34if bearExhaustion
35 strategy.close("Fade Short", comment="Bear exhaustion")
36
37// Time-based exit: close after 10 bars if target not hit
38if strategy.position_size > 0 and bar_index - strategy.opentrades.entry_bar_index(0) > 10
39 strategy.close_all(comment="Time exit")

Bollinger Band Squeeze-to-Expansion Strategy

Bollinger Bands measure volatility using standard deviations around a moving average. When the bands squeeze tight (low bandwidth), volatility is compressing: an expansion is coming. The strategy enters when bandwidth expands after a squeeze, in the direction of the breakout. On BTC, Bollinger squeezes on the daily chart precede the biggest moves of the year. The bandwidth filter ensures you only trade after genuine compression, not random noise.

pine-Bollinger squeeze-to-expansion
1//@version=5
2strategy("BB Squeeze Expansion", overlay=true,
3 initial_capital=10000,
4 default_qty_type=strategy.percent_of_equity,
5 default_qty_value=95,
6 commission_value=0.075, slippage=2)
7
8bbLen = input.int(20, "BB Length")
9bbMult = input.float(2.0, "BB Multiplier")
10squeezeLen = input.int(120, "Squeeze Lookback")
11squeezePctl = input.float(10, "Squeeze Percentile (%)")
12atrMult = input.float(2.0, "ATR Stop Mult")
13
14// === BOLLINGER BANDS ===
15basis = ta.sma(close, bbLen)
16dev = ta.stdev(close, bbLen) * bbMult
17upper = basis + dev
18lower = basis - dev
19bandwidth = (upper - lower) / basis * 100
20
21// === SQUEEZE DETECTION ===
22// Bandwidth is in the bottom percentile of its lookback range
23bwMin = ta.lowest(bandwidth, squeezeLen)
24bwMax = ta.highest(bandwidth, squeezeLen)
25bwPctl = (bandwidth - bwMin) / (bwMax - bwMin) * 100
26isSqueeze = bwPctl < squeezePctl
27
28// Expansion: bandwidth was in squeeze, now expanding
29wasSqueeze = ta.barssince(isSqueeze) < 5
30expanding = bandwidth > bandwidth[1] and bandwidth[1] > bandwidth[2]
31
32atr = ta.atr(14)
33
34// === ENTRIES ===
35if wasSqueeze and expanding and close > upper
36 strategy.entry("BB Long", strategy.long)
37 strategy.exit("BB SL", "BB Long", stop=basis)
38
39if wasSqueeze and expanding and close < lower
40 strategy.entry("BB Short", strategy.short)
41 strategy.exit("BB SL S", "BB Short", stop=basis)
42
43// Exit when price returns to basis
44if strategy.position_size > 0 and close < basis
45 strategy.close("BB Long", comment="Back to mean")
46if strategy.position_size < 0 and close > basis
47 strategy.close("BB Short", comment="Back to mean")
48
49// === VISUALS ===
50plot(upper, "Upper BB", color.new(color.blue, 40))
51plot(basis, "Basis", color.new(color.gray, 40))
52plot(lower, "Lower BB", color.new(color.blue, 40))
53bgcolor(isSqueeze ? color.new(color.yellow, 90) : na)

Crypto-specific Bollinger considerations

Crypto assets have fatter tails than traditional markets. BTC routinely moves 3–4 standard deviations in a single day during liquidation cascades. This means Bollinger Band breakouts in crypto tend to produce larger moves than in forex or equities. However, it also means stop losses at the basis (middle band) get hit more often. Consider using 1.5x ATR below the basis as your stop for additional breathing room.

Put this lesson to work

Free on Thrive, no account needed.