自訂與社群 TrendCandle TransformNot an MT5 Function 在 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)

示意性 — 合成資料,非即時報價。

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
顯示公式與計算詳情

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.

訊號

Heikin-Ashi 提供的可回測訊號 — 及每個訊號適合的市場狀態。

Colour Flip

Builder 可實現
條件
HA close crosses its own HA open
最佳市場狀態
Trending
典型用法
The template's entry and its exit — one event does both

Unbroken Colour Run

Builder 可實現
條件
Several consecutive candles hold the same colour
最佳市場狀態
Trending
典型用法
A continuation filter — hold while the run is intact rather than acting on it

Flat Open, No Wick

進階邏輯
條件
A body with no wick on the trailing side of the move
最佳市場狀態
Trending
典型用法
The classic strength reading; needs the wick, which the node does not publish

Shrinking Bodies

進階邏輯
條件
Same colour, but each body smaller than the last
最佳市場狀態
Either regime
典型用法
A discretionary fade signal — requires comparing body sizes across bars

MT5 實作

MetaTrader 5 實際計算與繪製的內容——本頁每條規則的依據。

平台說明

最佳適用場景 / 謹慎使用

沒有任何指標具有普適優勢。以下是 Heikin-Ashi 發揮作用的場景 — 以及可能誤導的場景。

最佳適用場景

  • 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

謹慎使用

  • 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

構建 Heikin-Ashi 策略

將訊號接入進場和出場規則,然後匯出可編譯的 MT5 EA — 無需撰寫程式碼。

  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

將 Heikin-Ashi 與其他指標組合

單一指標很少獨立有效。這些組合彌補了 Heikin-Ashi 的盲點。

Heikin-Ashi + ADX

  1. ADX above 25
  2. HA close crosses above HA open
  3. Buy
原因
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
最佳市場狀態
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.

開啟 Builder →

Heikin-Ashi + ATR

  1. ATR for the stop distance
  2. HA close crosses above HA open
  3. Buy
原因
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
最佳市場狀態
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.

開啟 Builder →

Heikin-Ashi + Supertrend

  1. Supertrend flipped up
  2. HA close crosses above HA open
  3. Buy
原因
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
最佳市場狀態
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.

開啟 Builder →

參數

在您自己的貨幣對和時間框架上驗證的起始值 — 非保證設置。

參數 預設值 建議測試範圍 功能說明
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.

初始預設

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

市場示例

Heikin-Ashi 有效的場景、失效的場景,以及篩選器如何改變結果。

有效

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.

失效

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.

已篩選

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.

Glossary

關鍵術語