Renko Brick Builder
Most published Renko implementations quietly repaint: they draw the currently-forming brick as if it were final, and redraw it (sometimes changing its shape) as price keeps moving before the box actually completes. Anything that reads a Renko series for signals - and Renko is popular specifically because its noise-filtering makes it attractive for signals - inherits that repaint the moment it looks at the last element of the array. This library never exposes a forming brick. RK_OnPrice compares each new price only against 'lastClose', the close of the last CONFIRMED brick, and returns a brick only at the instant a full box size has been covered. If a single price update covers several box widths at once - a stopped-out session reopening after a weekend gap, for example - RK_OnPrice loops and returns every brick that move produced, in order, rather than silently collapsing the gap into one oversized brick or skipping it. Renko brick direction reverses using the "one box reverses" convention: once price moves a full box against the last confirmed close, a brick in the new direction confirms immediately. Some charting platforms instead require a full TWO box move to reverse direction (the classic convention). This library uses the one-box rule because it is the simpler, more commonly implemented behaviour and is stated plainly here so a downloader comparing bricks against another platform's Renko chart understands exactly why the boundaries can differ. RK_BuildFromSeries converts an entire existing price history into confirmed bricks in one call, for backtesting a Renko-based strategy or feeding another indicator's input series without re-deriving the streaming logic. Notes and limitations - 'boxSize' is a raw price distance, already converted from pips if needed - this header never reads MODE_DIGITS or Point itself, since it has no symbol context of its own. - Uses one-box reversal, not the classic two-box convention some charting platforms default to. Brick boundaries will differ from a two-box Renko chart of the same instrument at the same box size - this is a documented design choice, not a bug. - direction is returned as a plain int, +1 for an up brick and -1 for a down brick, rather than an enum, to keep the header free of any type a caller would need to import separately. - RK_BuildFromSeries treats the first price in the series purely as the starting reference point - it produces no brick of its own, since a single price cannot itself represent a completed move. - A box size that is too small relative to the instrument's typical tick noise produces a very high brick count; a box size too large can hide moves a strategy cares about. Both are calibration choices for the caller, not something this library can validate on your behalf.
Script · MT4 · v1.0 · Free
About Renko Brick Builder
Renko Brick Builder is a script for MetaTrader 4. It has 1 setting, such as Box size. MQL source code included.
Files in the download: RenkoBuilder.mqh, RenkoBuilder.txt, RenkoBuilderDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Box size | 0.0020 | Brick size, in raw price units |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Renko · Buy/Sell Arrows · MT4 Script · MQL4 Source Code