πŸ”“ Get All Tools for FREE!

  • βœ… Click here to open a trading account using our referral link and start trading.
  • πŸ“… After 7 days of active trading under our referral link, you can get access to all tools in your account.
  • ⚠️ Keep trading to keep access free β€” if you're inactive for 7 days, your access will be removed.
  • πŸ‘‰ Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!

Smoothed Heikin Ashi Pullback Engulfing Strategy [algo_aakash] | Advanced Trend Following Indicator

Many traders struggle with identifying high-probability pullback opportunities within strong trends. Entering too early can lead to false signals, while entering too late often reduces profit potential. This TradingView Pine Script indicator combines Smoothed Heikin Ashi trend detection, pullback confirmation, and engulfing candle patterns to create a structured and disciplined trading system.

Unlike traditional Heikin Ashi indicators, this strategy uses Smoothed Heikin Ashi (SHA) candles to reduce market noise and provide a clearer view of trend direction. Once a trend is established, the indicator waits for a pullback and then looks for a bullish or bearish engulfing candle before generating a signal.

πŸ”“ Get All Tools for FREE!

  • βœ… Click here to open a trading account using our referral link and start trading.
  • πŸ“… After 7 days of active trading under our referral link, you can get access to all tools in your account.
  • ⚠️ Keep trading to keep access free β€” if you're inactive for 7 days, your access will be removed.
  • πŸ‘‰ Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!

Strategy Overview

This indicator combines three powerful trading concepts:

  • Smoothed Heikin Ashi Trend Detection
  • Pullback Identification
  • Engulfing Candle Confirmation

The result is a system designed to identify potential trend continuation opportunities after temporary market retracements.

How The Strategy Works

Bullish Setup

The indicator starts monitoring for bullish opportunities when:

  • Smoothed Heikin Ashi candles change from Red to Green
  • A new bullish trend is detected

Once the trend begins:

  • Price must pull back into the SHA candle body
  • A Bullish Engulfing candle must form
  • The setup must occur within the defined expiry period

When all conditions are satisfied, a BUY signal is generated.

Bearish Setup

The indicator starts monitoring for bearish opportunities when:

  • Smoothed Heikin Ashi candles change from Green to Red
  • A new bearish trend begins

After trend confirmation:

  • Price pulls back into the SHA candle body
  • A Bearish Engulfing candle appears
  • The setup remains valid within the expiry window

A SELL signal is then generated.

Setup Expiry Protection

One unique feature of this strategy is the setup expiry mechanism.

If a pullback and engulfing pattern do not occur within the specified number of bars:

  • The setup automatically expires
  • The indicator waits for a new trend setup

This helps avoid taking outdated signals after momentum has already weakened.

Indicator Features

βœ… Smoothed Heikin Ashi Candles

βœ… Automatic Trend Detection

βœ… Pullback Recognition

βœ… Bullish Engulfing Confirmation

βœ… Bearish Engulfing Confirmation

βœ… Setup Expiry Logic

βœ… BUY & SELL Labels

βœ… TradingView Alerts Included

βœ… Forex, Crypto & Stock Market Compatible

Why Use Smoothed Heikin Ashi?

Traditional candles often produce excessive market noise.

Smoothed Heikin Ashi helps traders:

  • Identify trends more clearly
  • Reduce false reversals
  • Stay in trends longer
  • Avoid emotional decision-making

This makes SHA particularly useful for trend-following traders.

Best Timeframes

Recommended timeframes:

  • 15 Minute
  • 30 Minute
  • 1 Hour
  • 4 Hour
  • Daily

Suitable for:

  • Forex Markets
  • Cryptocurrency Trading
  • Stock Market Trading
  • Indices
  • Commodities

Risk Management Tips

For best results:

  • Place stop loss below recent swing lows for BUY trades
  • Place stop loss above recent swing highs for SELL trades
  • Trade in the direction of higher timeframe trends
  • Avoid entering immediately before major news events
  • Use proper risk-to-reward ratios

Conclusion

The Smoothed Heikin Ashi Pullback Engulfing Strategy combines trend analysis, pullback detection, and candlestick confirmation into a structured trading approach. By waiting for a trend, a pullback, and an engulfing pattern to align, traders can focus on higher-quality setups while filtering out many low-probability entries.

Whether you trade Forex, Crypto, Stocks, or Indices, this Pine Script indicator provides a powerful framework for identifying potential trend continuation opportunities with clear entry signals and disciplined trade management.

Full Pine Script Code

//@version=5
indicator("SHA Pullback Engulfing Signals (15-Bar Expiry)", overlay=true)

// Paste your complete code here
// This source code is subject to the terms of the Mozilla Public License 2.0
// Β© wallneradam + Modified

//@version=5
indicator("SHA Pullback Engulfing Signals (15-Bar Expiry)", overlay=true, max_labels_count=500, timeframe="", timeframe_gaps=true)

import wallneradam/TAExt/8

//────────────────────────────────────
// Inputs
//────────────────────────────────────
ha_smooth_length = input.int(10, "Smooth Length", minval=1, group="Before HA")

ha_smooth_ma_type = input.string(
     "EMA",
     "MA Type",
     options=["SMA", "EMA", "WMA", "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "SWMA", "SMMA", "JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"],
     group="Before HA")

ha_after_smooth_length = input.int(10, "After Smooth Length", minval=1, group="After HA")

ha_after_smooth_ma_type = input.string(
     "EMA",
     "After MA Type",
     options=["SMA", "EMA", "WMA", "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "SWMA", "SMMA", "JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"],
     group="After HA")

setupExpiryBars = input.int(15, "Setup Expiry Bars", minval=1, group="Signals")
showSHA         = input.bool(true, "Show SHA Candles", group="Display")

//────────────────────────────────────
// Smoothed Heiken Ashi
//────────────────────────────────────
[o, h, l, c] = TAExt.heiken_ashi(
     smooth_length = ha_smooth_length,
     smooth_ma_type = ha_smooth_ma_type,
     after_smooth_length = ha_after_smooth_length,
     after_smooth_ma_type = ha_after_smooth_ma_type)

//────────────────────────────────────
// SHA Trend
//────────────────────────────────────
isGreen = c > o
isRed   = c < o

shaBodyHigh = math.max(o, c)
shaBodyLow  = math.min(o, c)

//────────────────────────────────────
// SHA Color Change
//────────────────────────────────────
bullTrendStart = isGreen and isRed[1]
bearTrendStart = isRed and isGreen[1]

//────────────────────────────────────
// State Variables
//────────────────────────────────────
var bool bullSetup = false
var bool bearSetup = false

var bool bullPullbackSeen = false
var bool bearPullbackSeen = false

var int bullSetupBars = 0
var int bearSetupBars = 0

//────────────────────────────────────
// Start New Setups
//────────────────────────────────────
if bullTrendStart
    bullSetup := true
    bearSetup := false

    bullPullbackSeen := false
    bearPullbackSeen := false

    bullSetupBars := 0
    bearSetupBars := 0

if bearTrendStart
    bearSetup := true
    bullSetup := false

    bullPullbackSeen := false
    bearPullbackSeen := false

    bullSetupBars := 0
    bearSetupBars := 0

//────────────────────────────────────
// Count Setup Age
//────────────────────────────────────
if bullSetup
    bullSetupBars += 1

if bearSetup
    bearSetupBars += 1

//────────────────────────────────────
// Pullback Detection
// Touch of SHA Body
//────────────────────────────────────
bullBodyTouch =
     low <= shaBodyHigh and high >= shaBodyLow

bearBodyTouch =
     high >= shaBodyLow and
     low <= shaBodyHigh

if bullSetup and bullBodyTouch
    bullPullbackSeen := true

if bearSetup and bearBodyTouch
    bearPullbackSeen := true

//────────────────────────────────────
// Invalidation
//────────────────────────────────────
bullInvalid =
     bullSetup and
     close < shaBodyLow bearInvalid = bearSetup and close > shaBodyHigh

if bullInvalid
    bullSetup := false
    bullPullbackSeen := false
    bullSetupBars := 0

if bearInvalid
    bearSetup := false
    bearPullbackSeen := false
    bearSetupBars := 0

//────────────────────────────────────
// Expire Setup After X Bars
//────────────────────────────────────
bullExpired =
     bullSetup and
     bullSetupBars > setupExpiryBars

bearExpired =
     bearSetup and
     bearSetupBars > setupExpiryBars

if bullExpired
    bullSetup := false
    bullPullbackSeen := false
    bullSetupBars := 0

if bearExpired
    bearSetup := false
    bearPullbackSeen := false
    bearSetupBars := 0

//────────────────────────────────────
// Bullish Engulfing
//────────────────────────────────────
bullEngulf =
     close > open and
     close[1] < open[1] and
     open <= close[1] and close >= open[1]

//────────────────────────────────────
// Bearish Engulfing
//────────────────────────────────────
bearEngulf =
     close < open and close[1] > open[1] and
     open >= close[1] and
     close <= open[1]

//────────────────────────────────────
// Entry Signals
// Must occur within setupExpiryBars
//────────────────────────────────────
buySignal =
     bullSetup and
     bullSetupBars <= setupExpiryBars and
     bullPullbackSeen and
     bullEngulf

sellSignal =
     bearSetup and
     bearSetupBars <= setupExpiryBars and
     bearPullbackSeen and
     bearEngulf

//────────────────────────────────────
// Reset After Entry
//────────────────────────────────────
if buySignal
    bullSetup := false
    bullPullbackSeen := false
    bullSetupBars := 0

if sellSignal
    bearSetup := false
    bearPullbackSeen := false
    bearSetupBars := 0

//────────────────────────────────────
// Plot SHA Candles
//────────────────────────────────────
plotcandle(
     showSHA ? o : na,
     showSHA ? h : na,
     showSHA ? l : na,
     showSHA ? c : na,
     title = "Smoothed Heiken Ashi",
     color = isRed ? color.new(color.red, 60) : color.new(color.lime, 60),
     wickcolor = isRed ? color.new(color.red, 20) : color.new(color.lime, 20),
     bordercolor = isRed ? color.new(color.red, 10) : color.new(color.lime, 10))

//────────────────────────────────────
// Signals
//────────────────────────────────────
plotshape(
     buySignal,
     title="BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.lime,
     text="BUY",
     textcolor=color.white,
     size=size.small)

plotshape(
     sellSignal,
     title="SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.red,
     text="SELL",
     textcolor=color.white,
     size=size.small)

//────────────────────────────────────
// Alerts
//────────────────────────────────────
alertcondition(
     buySignal,
     title="BUY Signal",
     message="SHA Bullish Pullback + Bullish Engulfing")

alertcondition(
     sellSignal,
     title="SELL Signal",
     message="SHA Bearish Pullback + Bearish Engulfing")

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *