Custom & community TrendCandle TransformNot an MT5 Function Available in Builder

Heikin-Ashi

Heikin-Ashi replaces the candles rather than adding anything to the chart. Each close is that bar's four prices averaged and each open the midpoint of the candle before it, so the bars chain together and the sequence smooths itself. MetaTrader 5 ships it as a custom indicator, but MQL5 has no iHeikenAshi function — the Builder folds the two lines into the generated EA instead.

Lines the node exposes
2
Seed lookback
120
Handles created
0
Heikin-Ashi candles (solid) over the market's own bars (outlined)Zero — the colour change, and the template's entryHeikin-Ashi body (HA close − HA open)

Illustrative — synthetic data, not a live quote.

What Heikin-Ashi tells you

Every other indicator on this site draws something next to the chart. This one redraws the chart. The close of each candle becomes the average of its own open, high, low and close, and the open becomes the midpoint of the previous Heikin-Ashi candle — so each bar inherits from the one before it and the sequence smooths itself as it goes. Runs of one colour become longer and cleaner, and the small opposite bars that punctuate a real trend mostly disappear. What you gain in readability you pay for in fidelity: the bodies on screen are not prices the market ever traded at.

  • There is no period and no smoothing constant — the chaining is the smoothing
  • The colour is one comparison, which is why a flip is unambiguous
  • The drawn body is a derived level, not a tradable price
  1. 1 HA close = this bar's open, high, low and close, averaged
  2. 2 HA open = the midpoint of the previous HA candle
  3. 3 Colour = HA close against HA open, nothing else
Show the formula & calculation detail

Heikin-Ashi is not an overlay. It is the candles, recalculated:

  1. HA close = this bar’s open, high, low and close, averaged
  2. HA open = the midpoint of the previous Heikin-Ashi candle
  3. HA high / low = the furthest out of the real extreme and those two levels

Step 2 is the whole indicator. Because each open is built from the candle before it, every bar carries the previous one inside it, and the chain smooths the sequence as it goes. There is no period to choose and no smoothing constant — the chaining is the smoothing.

MetaTrader 5 ships it, and MQL5 still has no function for it. Both halves are true and they are usually conflated. Heiken_Ashi.mq5 is in MQL5\Indicators\Examples, drawing with DRAW_COLOR_CANDLES across five buffers, and you can add it from the Navigator. But an EA that calls iHeikenAshi does not compile — the identifier does not exist. Reaching the bundled indicator from code means iCustom and a file path, which makes the EA depend on that file being present wherever it runs.

The Builder takes neither route. It folds the recurrence into the generated source:

ha_close = (open + high + low + close) / 4
ha_open  = (previous ha_open + previous ha_close) / 2

seeded 120 bars back and walked forward. No indicator handle is created at all — the node sits in the codegen’s no-handle list next to Price and OHLC, which is why the buffer table above is empty rather than short.

Three things follow for anyone building with it.

Colour takes two nodes. Each node returns one line, and the colour is one line against the other. A flow that wants to know whether the candle is bullish places a node on HACLOSE, a second on HAOPEN, and compares them. There is no colour output, and there could not be one — it is a comparison, not a value.

The drawn levels are not prices. A Heikin-Ashi close is an average of four numbers and an open is a midpoint of the candle before it. Neither was ever quoted, and fills still happen at the real bid and ask. This is the practical cost of the transform, and it is easy to forget precisely because the result looks like a normal chart.

The template closes before it opens, deliberately. A colour flip does two things at once: it ends the position on one side and starts one on the other. In the generated code the close runs first. Sent in the other order, a netting account nets the reversing order against the position it was meant to replace and leaves the account flat — while a hedging account behaves correctly either way, which is what makes the bug hard to see.

The seed differs from MT5’s, and only the open notices. A Heikin-Ashi close is that bar’s own four prices averaged, so it is the same number no matter where the calculation began. The open is the part that chains, and there the bundled indicator starts bar 0 at the raw open while the Builder starts its lookback back at a midpoint. Each step halves whatever the seed got wrong, which converges quickly: on synthetic series the gap is about 3e-5 of a price unit after 16 bars, 5e-10 after 32, and exactly zero in double precision by 64. The 120 the codegen uses is roughly twice what that needs.

Signals

The distinct, backtestable signals Heikin-Ashi gives — and the regime each one suits.

Colour Flip

Builder ready
Condition
HA close crosses its own HA open
Best regime
Trending
Typical use
The template's entry and its exit — one event does both

Unbroken Colour Run

Builder ready
Condition
Several consecutive candles hold the same colour
Best regime
Trending
Typical use
A continuation filter — hold while the run is intact rather than acting on it

Flat Open, No Wick

Advanced logic
Condition
A body with no wick on the trailing side of the move
Best regime
Trending
Typical use
The classic strength reading; needs the wick, which the node does not publish

Shrinking Bodies

Advanced logic
Condition
Same colour, but each body smaller than the last
Best regime
Either regime
Typical use
A discretionary fade signal — requires comparing body sizes across bars

MT5 implementation

What MetaTrader 5 itself computes and draws — the reference every rule on this page is written against.

Platform notes

Works best / use carefully

No indicator is a universal edge. Here is where Heikin-Ashi helps — and where it misleads.

Works best

  • Trends you intend to hold, where the value is in not being shaken out by one bar against you
  • Higher timeframes, where the chaining has bars long enough to be worth smoothing
  • As a way to read a chart you already trade, rather than as a trigger on its own
  • Anywhere the decision is directional rather than about an exact level

Use carefully

  • Ranges, where the colour flips repeatedly and every flip is a full reversal for a template that trades them
  • Reading an entry price off the candle — the body is an average, and fills happen at the real bid and ask
  • Very short timeframes, where the one-bar lag the chaining introduces is a large share of the move
  • Backtests that look unusually smooth: the equity curve is real, the candles that suggested it are not prices

Build a strategy with Heikin-Ashi

Wire the signal into entry and exit rules, then export a compilable MT5 EA — no code.

  1. Two Heikin-Ashi nodes — one reading HACLOSE, one reading HAOPEN
  2. Two crosses between them, one each way
  3. HA close crosses above HA open → Close the short, then Open Buy · SL 60 / TP 180
  4. HA close crosses below HA open → Close the long, then Open Sell
  5. The close nodes are placed ahead of the entries, and the order matters

Combine Heikin-Ashi with other indicators

One indicator rarely stands alone. These pairings cover Heikin-Ashi's blind spots.

Heikin-Ashi + ADX

  1. ADX above 25
  2. HA close crosses above HA open
  3. Buy
Why
The colour flip is a direction with no strength attached, and in a range it flips on noise that the smoothing has already made look convincing. A trend-strength reading is the direct answer to that: it does not improve the flip, it decides whether the flip is worth acting on. This is the pairing that addresses the template's one real weakness
Best regime
Trending

No single-flow template pairs them. Start from Heikin-Ashi Colour Flip, add an ADX node with a Compare at 25, and join it to the existing Cross with an And gate.

Open Builder →

Heikin-Ashi + ATR

  1. ATR for the stop distance
  2. HA close crosses above HA open
  3. Buy
Why
The template's stop is a fixed 60 pips, which is a guess about a market it has not measured. True range gives the same stop a size drawn from current conditions, and the pairing is natural here because Heikin-Ashi deliberately hides volatility — the smoothed bodies make a violent market look orderly, so the one number that is not smoothed is worth having next to it
Best regime
Either regime

No single-flow template combines them. Add an ATR node to Heikin-Ashi Colour Flip and use it in the money-management node rather than in the entry condition.

Open Builder →

Heikin-Ashi + Supertrend

  1. Supertrend flipped up
  2. HA close crosses above HA open
  3. Buy
Why
Two ways of answering the same question, and instructive precisely because they disagree. Supertrend flips when price crosses a band placed a multiple of true range away, so it needs a real excursion; Heikin-Ashi flips when an average crosses another average, so it turns earlier and more often. Requiring both is a slower entry that discards most of the flips that would have been given straight back
Best regime
Trending

No single-flow template pairs them. Add a Supertrend node and a Price node into a Compare, then join that to the Heikin-Ashi Cross with an And gate.

Open Builder →

Parameters

Starting values to validate on your own pair and timeframe — not guaranteed settings.

Parameter Default Suggested test range What it does
Line HACLOSE HACLOSE / HAOPEN Which of the two lines the node returns. It is a property of one node rather than two node types, so reading the colour — which is one against the other — takes two nodes with this set differently. That is exactly what the template does, and it is the only way to get a colour out of the Builder.
Shift 1 0–100 How many bars back the value is read. At 1 it is the last closed bar, which is what makes a flip a finished fact. At 0 the bar still forming is read, and its Heikin-Ashi close moves with every tick — the colour can change and change back within one bar. Unlike some indicators here, 0 is not broken; it is just an unfinished reading.
Timeframe Current Current / M1–MN1 Which timeframe's bars the candles are built from. Set it higher than the chart and the colour becomes a slower directional backdrop for entries timed on the chart's own bars, which is the usual way to use it as a filter rather than a trigger.

Starting presets

Closed bar Shift 1 The template's setting — the flip is a fact, not a work in progress
Higher-timeframe bias H4 on an H1 chart Colour as a filter, timing left to the faster chart
Live bar Shift 0 Reacts sooner, and can change its mind inside a single bar

Market examples

Where Heikin-Ashi works, where it fails, and how a filter changes the outcome.

Works

A run that held

The colour flips once and then holds for a dozen bars while the real candles alternate several times inside it. The position is opened on the flip and never sees a close condition until the move is over — which is the entire case for the transform.

Fails

Two flips in three bars

A sideways stretch produces a flip, a reversal on the next bar, and a third flip after it. Each one closes a position and opens the opposite, so a quiet market is the expensive case for a template that reverses on every colour change.

Filtered

The flip that was ignored

The same choppy stretch with a trend-strength filter attached. The flips still happen and the colour still changes; no order is sent, because the condition the flip is joined to was never true.

FAQ

Does MetaTrader 5 have Heikin-Ashi?
Yes and no, and the distinction matters for anyone building an EA. The terminal ships a Heiken Ashi custom indicator in Indicators\Examples, so you can drop it on a chart from the Navigator. But MQL5 has no iHeikenAshi function — code that calls one does not compile. Reaching the bundled indicator from an EA means iCustom and a path, which ties the EA to a file being present on whichever terminal runs it. The Builder avoids that entirely by folding the calculation into the generated source.
What is the formula?
The close of each candle is that bar's open, high, low and close averaged. The open is the midpoint of the previous Heikin-Ashi candle — its open and its close, averaged. The wicks, which MT5's indicator draws but the Builder's node does not publish, extend to whichever is furthest out of the real extreme and the two Heikin-Ashi levels. There is no period and no smoothing factor anywhere in it.
How do I get the candle colour in the Builder?
With two nodes. Colour is one line against the other, and each node returns only one of them, so the flow places a Heikin-Ashi node set to HACLOSE and a second set to HAOPEN and compares them. Close above open is bullish. The template does exactly this, and the crossing of the two is what it trades.
Can I enter at the Heikin-Ashi price shown on the candle?
No, and this is the most common way the indicator is misused. Those levels are averages — the close is four prices divided by four, the open is a midpoint of the candle before it. Neither was ever quoted. Orders fill at the real bid and ask, so a stop placed just under a Heikin-Ashi body is placed against a number the market does not know about.
Why does the template close before it opens?
Because the reverse order breaks on netting accounts. Both actions fire on the same flip, and if the new order is sent first, a netting account offsets it against the position it was meant to replace and leaves the account flat rather than reversed. Closing first makes the sequence correct on netting and hedging accounts alike. On a hedging account either order happens to work, which is precisely why it is easy to get wrong.
Can I build a Heikin-Ashi EA without coding?
Yes. The Heikin-Ashi Colour Flip template uses two Heikin-Ashi nodes and two crosses: the close crossing above the open closes any short and opens a long, and the reverse crossing does the opposite. The shift, the stop and target distances, the lot and the spread limit are all EA inputs, and no external indicator file is needed on the terminal that runs it.
How should I validate settings before going live?
Backtest on quality tick data, then demo, and read the trade list rather than only the curve. Two cautions are specific to this transform. Because a colour flip both closes and opens, the trade count is set by how often the market changes character — check that the number of reversals in the test is one you would actually have sat through. And because the candles are averages, an equity curve built from them can look smoother than the market that produced it; compare the drawdown against the real price range over the same period rather than against the chart.