Nicolas

Heikin Ashi Scalper: candles graded by strength, a slow trend ribbon and pullback flips

Studio Only
Category: Indicators By: Nicolas Created: December 4, 2026, 4:40 PM
December 4, 2026, 4:40 PM
Indicators
0 Comments
ProRealCode Script
Heikin Ashi Scalper: candles graded by strength, a slow trend ribbon and pullback flips

Heikin Ashi Scalper draws Heikin Ashi candles on the price chart and grades each of them by strength: a candle with no wick against its direction is drawn in full colour, an ordinary one is paler, and an indecision candle is grey. Under the candles, a slow trend line with a green or red ribbon gives the direction of the larger move. An arrow marks each time the candles change colour back in the direction of that slow trend, which is where a pullback ends. Every finished run of candles of the same colour is labelled with its length and the points it moved, and a table sums up the last candle, the current run and the trend. It is built for short timeframes, one to five minutes, on index futures and other liquid instruments.

This code is written in ProRealCode Script and runs with ProRealCode Studio on ProRealTime Web.

Heikin Ashi Scalper on a 1-minute Mini DAX chart: graded Heikin Ashi candles, a green and red slow trend ribbon, arrows on the flips with the trend, labelled runs and the summary table

Mini DAX future, 1 minute, dark theme, from 11:40 to 15:30. Seventeen runs of 5 candles or more are labelled: green runs of 8 · +26, 5 · +6, 8 · +16, 12 · +22, 9 · +34, 6 · +12, 8 · +19, 7 · +38, 5 · +19, 7 · +16 and 6 · +9, red runs of 7 · +7, 8 · +19, 8 · +19, 6 · +6, 8 · +43 and 7 · +4 (the first figure is the number of candles, the second the points the run moved in its own direction). The ribbon is green along the climbs and red along the falls. The table describes the last candle: a grey indecision candle at the end of a run of 8 red candles that has moved 22 points, in a slow trend down for 7 candles, so the run follows the trend. Over the loaded history a green run lasts 4.2 candles and a red one 4 candles, and the last 20 candles hold 4 strong up candles and 5 strong down.

What a Heikin Ashi candle is, and why scalpers use it

A Heikin Ashi candle is computed from the real candle, and from the Heikin Ashi candle before it:

  • Its close is the average of the four prices of the candle: open, high, low and close.
  • Its open is the middle of the body of the previous Heikin Ashi candle.
  • Its high and low are the highest and the lowest of the real high or low, the Heikin Ashi open and the Heikin Ashi close.

Because each open leans on the candle before, the candles keep their colour while a move lasts and only change colour when the move really slows down. A trend on a one-minute chart, which looks like a jumble of green and red real candles, turns into a clean run of green Heikin Ashi candles. That is why scalpers use them: the colour answers “is the move still going?” at a glance, and the shape of the candle says how strongly.

1. The three grades of candle

Each candle is measured against its own range, from its high to its low:

  • Strong, full colour: the wick against the direction is 5 % of the range or less. A green candle with no lower wick, or a red one with no upper wick: the buyers, or the sellers, never gave ground during the candle.
  • Ordinary, paler: any other green or red candle. The fill is lighter, the outline keeps the full colour.
  • Indecision, grey: the body is less than 25 % of the range and each wick is more than 10 % of it. A small body between two wicks, neither side in control.

In a healthy move, the strong candles come in series. When the candles turn pale, then grey, the move is running out of breath, often before the colour changes.

Heikin Ashi Scalper on a 1-minute Mini DAX chart in light theme: an up trend with full colour, pale and grey candles, two red pullbacks and green arrows where the candles turn green again

Mini DAX future, 1 minute, light theme, a morning up trend from 09:18 to 11:12. Green runs of 12 · +37, 7 · +32, 21 · +69 and 11 · +29, red pullbacks of 7 · +29 and 9 · +18. The three grades are easy to see here: the strong legs are made of full green candles with no lower wick, the pale candles appear where the climb hesitates, and grey candles sit at the tops before each pullback. Each time the candles turn green again above a green ribbon, a green arrow is drawn under the candle.

2. The slow trend

The slow trend is a second Heikin Ashi, built on smoothed prices: the open, the high, the low and the close are each replaced by their exponential average over 10 candles, and the Heikin Ashi is computed from those four averages. Its close is drawn as a line, and the space between its open and its close is filled with a ribbon.

  • Green line and ribbon: the slow Heikin Ashi is green, the trend is up.
  • Red line and ribbon: it is red, the trend is down.

The ribbon is dense along the line and fades away from it. Its width says something too: a wide ribbon is a trend that is moving, a thin one is a trend that is slowing down and may turn. The slow trend changes colour far less often than the candles, which is the point: the candles give the rhythm, the ribbon gives the side.

3. The runs

A run is a series of Heikin Ashi candles of the same colour in a row. When the colour flips, the run that has just ended is measured:

  • Its length: the number of candles.
  • Its move: the points between the close before its first candle and its last close, counted in the direction of the run. A green run that rose 26 points reads +26, and so does a red run that fell 26 points.

The label is placed above the last candle of a green run and under the last candle of a red run, in the colour of the run. Runs shorter than 5 candles are not labelled, so the chart only shows the moves that mattered. The labels make it easy to see, over a session, how long a run usually lasts and how far it usually goes on that instrument.

4. The flips with the trend

When the candles change colour back in the direction of the slow trend, an arrow is drawn: a green arrow under the candle when they turn green while the slow trend is up, a red arrow above the candle when they turn red while the slow trend is down. This is the end of a pullback: the candles went against the trend for a while, and they are going with it again.

A flip against the slow trend is left unmarked. A green candle in a down trend is often only a bounce, and the code does not mark it.

The table

  • Last candle: its grade. “strong up · no lower wick” and “up” in green, “strong down · no upper wick” and “down” in red, “indecision · small body, two wicks” in amber.
  • Current run: how many candles of the same colour in a row, and the points the run has moved so far, counted like the labels.
  • Slow trend: up or down, and for how many candles. “not enough history” while the averages are still starting.
  • Run against trend: “no · the run follows the trend”, or “yes · a pullback, wait for the flip” in amber when the candles go against the slow trend.
  • Usual run: the average length of the green runs and of the red runs over the loaded history, every finished run counted, labelled or not.
  • Strong candles, last 20: how many strong up and strong down candles in the last 20, with a bar whose middle is zero. More strong up candles fill it past the middle in green, more strong down candles keep it short of the middle in red.

The table is a neutral grey card with its own text colours, so it reads the same on a dark and on a light chart.

Heikin Ashi Scalper on a 1-minute Mini Nasdaq 100 chart: labelled green and red runs, the slow trend ribbon and a large strong green candle that turns the ribbon green again

Mini Nasdaq 100 future, 1 minute, light theme. Green runs of 5 · +32.8, 5 · +29.8 and 12 · +65.3, red runs of 8 · +29, 5 · +16.5, 10 · +47.3 and 6 · +23.5. The last candle is a large strong green candle that turned the ribbon green again. The table reads “strong up · no lower wick”, 2 green candles in a row for +78.3 points, a slow trend up for 1 candle, a run that follows the trend, a usual run of 4 green and 3.9 red candles, and 9 strong up candles against 2 strong down over the last 20.

Settings and how to use it

Paste the code into a new Studio tab and run it on an intraday chart. The settings come in three sections, Slow trend, Signals and Display, and each one has a help text in the Settings form:

  • Smoothing of the slow trend (candles): 10 by default, 2 at least. The length of the exponential averages behind the slow trend. A larger value gives a slower trend and fewer arrows.
  • Ribbon of the slow trend: a switch, on by default. Off, only the slow trend line is drawn.
  • Arrows on the flips with the trend: a switch, on by default.
  • Label the runs of at least (candles): 5 by default. Shorter runs are not labelled. They still count in the usual run of the table.
  • Alert on a flip with the trend: a switch, off by default. On, an alert with a sound is sent when a candle closes on a flip in the direction of the slow trend.
  • Summary table: a switch, on by default.

Things to know before reading the chart:

  • The code draws its Heikin Ashi candles on top of the chart’s own candles. To keep only the Heikin Ashi candles, as in the captures, hide the price of the chart: untick Price in the legend at the top left of the chart.
  • A Heikin Ashi close is an average, not a traded price. The moves on the labels and in the table are measured on the real closes, not on the Heikin Ashi ones. This is why a run can, now and then, show a negative figure: the candles stayed green while the real closes slipped.
  • A grey candle still belongs to a run. Underneath the grey it has a colour, green or red, and that colour decides whether the run goes on or ends.
  • The candle in progress can still change colour until it closes. An arrow or a label that appears on it is only settled at the close.
  • The alert fires once, when a candle closes on a flip with the trend, in real time only. The flips in the history are drawn as arrows, not sent as alerts.
  • The moves are counted in points as the instrument counts them: points on an index, pips on a currency pair.

A typical reading: the ribbon is green and wide, the candles have just made a strong green run, and a short red run starts against it. The table says “yes · a pullback, wait for the flip” in amber. The red candles are pale or grey, never full red: the sellers are not pressing. Then the first green candle closes, the arrow appears under it, and the table goes back to “no · the run follows the trend”. The reading is cleaner when that green candle is drawn in full colour, when the bar of strong candles leans to the green, and when the pullback stayed shorter than the usual red run. The mirror reading holds in a down trend. A run that has already lasted twice the usual length is a mature move, not a fresh one. Each of these is a reason. None of them is a signal on its own.

Under the hood

The candles are drawn with DRAWCANDLE, with a fill opacity for the pale and grey grades and a separate outline colour, and the arrows with DRAWARROWUP and DRAWARROWDOWN. The code also shows several additions of ProRealCode Script: COLORBETWEEN with two colours for a ribbon that fades from one edge to the other, input() settings of int and switch types grouped in sections with their help texts, DRAWLABEL for the runs, alert() for the flips with the trend, and a table built with DRAWTABLE, TABLEMERGE, TABLECELL, and TABLEBAR for the balance of strong candles.

//----------------------------------------------------------------
// PRC_Heikin Ashi Scalper | indicator
// Author: Nicolas
// Date: 04.12.2026
// https://www.prorealcode.com
// License: CC BY-NC 4.0 - free to use, share and modify for
// non-commercial purposes, provided the author and the source
// above are credited.
// https://creativecommons.org/licenses/by-nc/4.0/
//----------------------------------------------------------------
// Heikin Ashi candles graded by strength, on a slow trend. A candle
// with no wick against its direction is drawn in full colour, an
// ordinary one is paler and an indecision candle is grey. A ribbon
// gives the slow trend, itself a smoothed Heikin Ashi. An arrow marks
// each flip of the candles back in the direction of the slow trend,
// every finished run is labelled with its length and its gain, and a
// table sums up the candle, the run and the trend.
// Runs with ProRealCode Studio: https://www.prorealcode.com/prorealcode-studio/
//----------------------------------------------------------------

DEFPARAM overlay = true

input(slowLen, 10, "Smoothing of the slow trend (candles)", int, minval = 2, group = "Slow trend", tooltip = "The slow trend is a Heikin Ashi built on prices averaged over this many candles. A larger value gives a slower trend and fewer arrows.")
input(showRibbon, 1, "Ribbon of the slow trend", bool, group = "Slow trend", tooltip = "Fills the body of the slow Heikin Ashi: green in an up trend, red in a down trend.")
input(showEntries, 1, "Arrows on the flips with the trend", bool, group = "Signals", tooltip = "An arrow when the candles change colour back in the direction of the slow trend: the end of a pullback.")
input(minRun, 5, "Label the runs of at least (candles)", int, minval = 1, group = "Signals", tooltip = "When a run of candles of the same colour ends, a label gives its number of candles and the points it gained. Shorter runs are not labelled.")
input(useAlerts, 0, "Alert on a flip with the trend", bool, group = "Signals", tooltip = "One alert with a sound when a candle closes on a flip in the direction of the slow trend.")
input(showTable, 1, "Summary table", bool, group = "Display", tooltip = "The last candle, the current run, the slow trend, the usual length of a run and the share of strong candles.")

// -- 1. The Heikin Ashi candle ----------------------------------------
// Its close is the average of the four prices of the candle, its open
// the middle of the body of the Heikin Ashi candle before.
haClose = (open + high + low + close) / 4
once haOpen = (open + close) / 2
IF barindex > 0 THEN
    haOpen = (haOpen[1] + haClose[1]) / 2
ENDIF
haHigh = MAX(high, MAX(haOpen, haClose))
haLow = MIN(low, MIN(haOpen, haClose))
body = ABS(haClose - haOpen)
rng = haHigh - haLow
upWick = haHigh - MAX(haOpen, haClose)
dnWick = MIN(haOpen, haClose) - haLow
dir = 0 - 1
IF haClose >= haOpen THEN
    dir = 1
ENDIF

// -- 2. Its strength --------------------------------------------------
// 2 or -2: no wick against the direction, buyers or sellers never gave
// ground. 1 or -1: an ordinary candle. 0: a small body between two
// wicks, an indecision.
kind = dir
IF rng > 0 THEN
    IF body < 0.25 * rng AND upWick > 0.1 * rng AND dnWick > 0.1 * rng THEN
        kind = 0
    ELSIF dir = 1 AND dnWick <= 0.05 * rng THEN
        kind = 2
    ELSIF dir = 0 - 1 AND upWick <= 0.05 * rng THEN
        kind = 0 - 2
    ENDIF
ENDIF
strongUp = 0
strongDn = 0
IF kind = 2 THEN
    DRAWCANDLE(haOpen, haHigh, haLow, haClose) COLOURED(38, 200, 140) BORDERCOLOR(38, 200, 140)
    strongUp = 1
ELSIF kind = 1 THEN
    DRAWCANDLE(haOpen, haHigh, haLow, haClose) COLOURED(38, 200, 140, 110) BORDERCOLOR(38, 200, 140)
ELSIF kind = 0 - 1 THEN
    DRAWCANDLE(haOpen, haHigh, haLow, haClose) COLOURED(235, 70, 85, 110) BORDERCOLOR(235, 70, 85)
ELSIF kind = 0 - 2 THEN
    DRAWCANDLE(haOpen, haHigh, haLow, haClose) COLOURED(235, 70, 85) BORDERCOLOR(235, 70, 85)
    strongDn = 1
ELSE
    DRAWCANDLE(haOpen, haHigh, haLow, haClose) COLOURED(150, 158, 172, 150) BORDERCOLOR(150, 158, 172)
ENDIF

// -- 3. The slow trend: a Heikin Ashi on smoothed prices --------------
eo = ExponentialAverage[slowLen](open)
eh = ExponentialAverage[slowLen](high)
el = ExponentialAverage[slowLen](low)
ec = ExponentialAverage[slowLen](close)
sClose = (eo + eh + el + ec) / 4
IF ISSET(sOpen[1]) AND ISSET(sClose[1]) THEN
    sOpen = (sOpen[1] + sClose[1]) / 2
ELSE
    sOpen = (eo + ec) / 2
ENDIF
trend = 0
IF ISSET(sOpen) AND ISSET(sClose) THEN
    IF sClose >= sOpen THEN
        trend = 1
    ELSE
        trend = 0 - 1
    ENDIF
ENDIF
once trendLen = 0
IF trend <> trend[1] THEN
    trendLen = 1
ELSE
    trendLen = trendLen + 1
ENDIF
cr = 150
cg = 158
cb = 172
IF trend = 1 THEN
    cr = 38
    cg = 200
    cb = 140
    IF showRibbon THEN
        COLORBETWEEN(sOpen, sClose, "#26c88c12", "#26c88c70")
    ENDIF
ELSIF trend = 0 - 1 THEN
    cr = 235
    cg = 70
    cb = 85
    IF showRibbon THEN
        COLORBETWEEN(sOpen, sClose, "#eb465512", "#eb465570")
    ENDIF
ENDIF

// -- 4. The runs: candles of the same colour in a row -----------------
// When the colour flips, the run that ends is measured, and labelled
// when it is long enough. Its gain is counted from the close before
// its first candle to its last close.
atr = AverageTrueRange[20](close)
once runDir = 0
once runLen = 0
once nUp = 0
once sumUp = 0
once nDn = 0
once sumDn = 0
flip = 0
IF dir <> runDir THEN
    IF runDir <> 0 THEN
        gain = ROUND((close[1] - runBase) * runDir / pipsize * 10) / 10
        endLen = runLen
        IF runDir = 1 THEN
            nUp = nUp + 1
            sumUp = sumUp + runLen
            IF runLen >= minRun THEN
                IF gain >= 0 THEN
                    DRAWLABEL(barindex - 1, high[1] + 0.6 * atr, "#endLen# · +#gain#", arrowdown, small) COLOURED(14, 18, 30) FILLCOLOR(60, 210, 150) BORDERCOLOR(60, 210, 150)
                ELSE
                    DRAWLABEL(barindex - 1, high[1] + 0.6 * atr, "#endLen# · #gain#", arrowdown, small) COLOURED(14, 18, 30) FILLCOLOR(60, 210, 150) BORDERCOLOR(60, 210, 150)
                ENDIF
            ENDIF
        ELSE
            nDn = nDn + 1
            sumDn = sumDn + runLen
            IF runLen >= minRun THEN
                IF gain >= 0 THEN
                    DRAWLABEL(barindex - 1, low[1] - 0.6 * atr, "#endLen# · +#gain#", arrowup, small) COLOURED(255, 255, 255) FILLCOLOR(240, 85, 95) BORDERCOLOR(240, 85, 95)
                ELSE
                    DRAWLABEL(barindex - 1, low[1] - 0.6 * atr, "#endLen# · #gain#", arrowup, small) COLOURED(255, 255, 255) FILLCOLOR(240, 85, 95) BORDERCOLOR(240, 85, 95)
                ENDIF
            ENDIF
        ENDIF
        flip = dir
        runBase = close[1]
    ELSE
        runBase = open
    ENDIF
    runDir = dir
    runLen = 1
ELSE
    runLen = runLen + 1
ENDIF

// -- 5. The flips with the trend --------------------------------------
// The candles turn back in the direction of the slow trend: a pullback
// ends. A flip against the slow trend is left unmarked.
IF flip <> 0 AND flip = trend THEN
    IF showEntries THEN
        IF flip = 1 THEN
            DRAWARROWUP(barindex, haLow - 0.5 * atr) COLOURED(38, 200, 140)
        ELSE
            DRAWARROWDOWN(barindex, haHigh + 0.5 * atr) COLOURED(235, 70, 85)
        ENDIF
    ENDIF
    IF useAlerts THEN
        IF flip = 1 THEN
            alert("Heikin Ashi scalper", "Flip up with the slow trend at #close#", onceperbarclose, 1)
        ELSE
            alert("Heikin Ashi scalper", "Flip down with the slow trend at #close#", onceperbarclose, 1)
        ENDIF
    ENDIF
ENDIF

nSU = Summation[20](strongUp)
nSD = Summation[20](strongDn)

// -- 6. The table -----------------------------------------------------
// A neutral grey card with its own text colours: it reads the same on
// a dark and on a light chart.
IF islastbarupdate AND showTable THEN
    board = DRAWTABLE(7, 2, topleft) FILLCOLOR(42, 45, 52, 245) BORDERCOLOR(84, 90, 102)
    TABLEMERGE(board, 0, 0, 1, 2)
    TABLECELL(board, 0, 0, "Heikin Ashi scalper", bold, center, 14) COLOURED(238, 240, 244)
    TABLECELL(board, 1, 0, "Last candle") COLOURED(168, 175, 188)
    IF kind = 2 THEN
        TABLECELL(board, 1, 1, "strong up · no lower wick", bold, right) COLOURED(70, 215, 155)
    ELSIF kind = 1 THEN
        TABLECELL(board, 1, 1, "up", right) COLOURED(70, 215, 155)
    ELSIF kind = 0 - 1 THEN
        TABLECELL(board, 1, 1, "down", right) COLOURED(255, 110, 120)
    ELSIF kind = 0 - 2 THEN
        TABLECELL(board, 1, 1, "strong down · no upper wick", bold, right) COLOURED(255, 110, 120)
    ELSE
        TABLECELL(board, 1, 1, "indecision · small body, two wicks", bold, right) COLOURED(250, 195, 80)
    ENDIF
    TABLECELL(board, 2, 0, "Current run") COLOURED(168, 175, 188)
    gNow = ROUND((close - runBase) * runDir / pipsize * 10) / 10
    IF runDir = 1 THEN
        IF gNow >= 0 THEN
            TABLECELL(board, 2, 1, "#runLen# green in a row · +#gNow#", right) COLOURED(70, 215, 155)
        ELSE
            TABLECELL(board, 2, 1, "#runLen# green in a row · #gNow#", right) COLOURED(70, 215, 155)
        ENDIF
    ELSE
        IF gNow >= 0 THEN
            TABLECELL(board, 2, 1, "#runLen# red in a row · +#gNow#", right) COLOURED(255, 110, 120)
        ELSE
            TABLECELL(board, 2, 1, "#runLen# red in a row · #gNow#", right) COLOURED(255, 110, 120)
        ENDIF
    ENDIF
    TABLECELL(board, 3, 0, "Slow trend") COLOURED(168, 175, 188)
    IF trend = 1 THEN
        TABLECELL(board, 3, 1, "up for #trendLen# candles", bold, right) COLOURED(70, 215, 155)
    ELSIF trend = 0 - 1 THEN
        TABLECELL(board, 3, 1, "down for #trendLen# candles", bold, right) COLOURED(255, 110, 120)
    ELSE
        TABLECELL(board, 3, 1, "not enough history", right) COLOURED(168, 175, 188)
    ENDIF
    TABLECELL(board, 4, 0, "Run against trend") COLOURED(168, 175, 188)
    IF trend = 0 THEN
        TABLECELL(board, 4, 1, "-", right) COLOURED(168, 175, 188)
    ELSIF runDir = trend THEN
        TABLECELL(board, 4, 1, "no · the run follows the trend", right) COLOURED(238, 240, 244)
    ELSE
        TABLECELL(board, 4, 1, "yes · a pullback, wait for the flip", bold, right) COLOURED(250, 195, 80)
    ENDIF
    TABLECELL(board, 5, 0, "Usual run") COLOURED(168, 175, 188)
    IF nUp > 0 AND nDn > 0 THEN
        aUp = ROUND(sumUp / nUp * 10) / 10
        aDn = ROUND(sumDn / nDn * 10) / 10
        TABLECELL(board, 5, 1, "green #aUp# · red #aDn# candles", right) COLOURED(238, 240, 244)
    ELSE
        TABLECELL(board, 5, 1, "not enough history", right) COLOURED(168, 175, 188)
    ENDIF
    TABLECELL(board, 6, 0, "Strong candles, last 20") COLOURED(168, 175, 188)
    // The middle of the bar is zero: more strong up candles fill past it
    IF nSU >= nSD THEN
        TABLEBAR(board, 6, 1, nSU - nSD, 0 - 20, 20, "#nSU# up · #nSD# down") COLOURED(70, 215, 155)
    ELSE
        TABLEBAR(board, 6, 1, nSU - nSD, 0 - 20, 20, "#nSU# up · #nSD# down") COLOURED(255, 110, 120)
    ENDIF
ENDIF

RETURN sClose COLOURED(cr, cg, cb) STYLE(line, 2) AS "Slow trend"
No ITF file for this code
A Studio Only code is not imported into ProRealTime™. Copy it and paste it into the ProRealCode Studio editor.
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...