Heikin Ashi ("average bar" in Japanese) is a candlestick technique that smooths price action. Each candle is built from averaged values instead of the raw open, high, low and close, so consecutive candles of the same color are easier to see and small counter-moves are filtered out. The formulas are:
HA Close = (Open + High + Low + Close) / 4 HA Open = (HA Open[prev] + HA Close[prev]) / 2 HA High = max(High, HA Open, HA Close) HA Low = min(Low, HA Open, HA Close)
The first candle of the history uses (Open + Close) / 2 as its HA open. Because every HA open depends on the previous HA candle, the indicator keeps the full history in its buffers and, after the first run, only recalculates the forming bar and new bars.
Many implementations draw Heikin Ashi in a separate window or as a custom symbol. This indicator draws the candles on the main chart, in the same price scale as the real candles. It can optionally hide the original candles, so the chart looks like a native Heikin Ashi chart while you keep working with the real symbol, its orders and its other indicators.
The indicator draws in the main chart window. For iCustom() the buffers are: 0 – HA open, 1 – HA high, 2 – HA low, 3 – HA close, 4 – color index (0 = bullish, 1 = bearish).
| Input | Default | Purpose |
|---|---|---|
| InpBullColor | clrWhite | Color of bullish Heikin Ashi candles. |
| InpBearColor | clrGray | Color of bearish Heikin Ashi candles. |
| InpHideChartCandles | true | Hide the original chart candles. The indicator saves the chart colors, paints candles, bars and line with the background color, and turns off the "Chart on foreground" option. Everything is restored in OnDeinit() . |
| InpShowStatus | true | Show or hide the on-chart status label. |
| InpCorner | CORNER_LEFT_UPPER | Chart corner in which the status label is placed. |
| InpStatusColor | clrWhite | Color of the status label text. |

Fig. 1. Heikin Ashi candles drawn over the chart with the original candles hidden (bullish – white, bearish – gray) and the status label; black & white image according to the Code Base image guidelines.
H4 Breakout Retest EA for Gold (XAUUSD)
Gold EA: breakout of the first H4 candle with confirmation via a retest, fixed percentage stop and target, risk-based lot size and drawdown protection.
Swap Cost Panel — tonight's rollover cost for every open position
On-chart panel that estimates tonight's swap for each open position in account currency, marks the triple-swap day, and compares it with the cost of closing before rollover and re-opening after (spread + commission).
Spread By Hour - average and max spread per hour, live spread vs usual
Average and maximum spread for each server hour from bar history, live spread vs the usual spread of this hour, and the spread cost of 1 lot.
Market Hours Label - is the symbol open now and when it closes
Small label on the chart. the symbol is open or closed now, the time left to the close or to the next open, and the sessions of today. It reads the trade sessions of your broker. Display only.