About
Renko draws a brick each time price has moved a fixed distance and ignores time. This plugin follows the classic rules. Bricks are built from closes only. The brick size never changes during a run: either a price distance you set, or ATR(atr_period) times atr_mult measured once, at the first bar where the ATR is known (Wilder's ATR, the same as ctx.ind("atr")), and then fixed. The first brick is measured from the close of that bar (the anchor), and every brick edge sits on the grid anchor + k times the size.
A brick in the same direction needs a close one size beyond the last brick's close. A reversal needs two sizes: a close one size beyond the last brick's open (the classic two brick reversal). One bar can add several bricks, all in the same direction.
Parameters
| Name | Type | Default | Range or options | Description |
|---|---|---|---|---|
mode | choice | "atr" | atr, fixed | How the brick size is set: "atr" measures ATR(atr_period) times atr_mult once at the start, "fixed" takes `size`. |
size | float | 0 | The brick size in price units for mode "fixed" (0.0010 is 10 pips on EURUSD). Must be above 0 there; mode "fixed" with 0 is refused and the call returns None. | |
atr_period | int | 14 | min 1, max 500 | Bars in Wilder's ATR for mode "atr". |
atr_mult | float | 1 | min 0.01, max 50 | The brick size as a multiple of that ATR, for mode "atr". |
Use it in a strategy
pythonrenko = ctx.plugin_indicator("renko_bricks", "renko", {"mode": "fixed", "size": 0.0010})
if renko is not None and renko.value is not None:
# Long after two up bricks in a row, out on a reversal down.
if renko.direction == 1 and renko.run >= 2:
ctx.signal("LONG")
elif renko.reversal and renko.direction == -1:
ctx.signal("EXIT")The indicator library has this as renko: ctx.ind("renko", mode="atr", atr_length=14, atr_mult=1.0) reads the same bricks (brick_close is the value here), and the chart, Blocks, Rust and the Rust core have it too. This template stays as an example of a plugin indicator.
What it provides
valueValue | The close of the last brick (its far edge in its direction). None until the first brick. |
brick_openValue | The open of the last brick, one size behind its close. None until the first brick. |
directionValue | 1 when the last brick went up, -1 when it went down. None until the first brick. |
new_bricksValue | How many bricks this bar added, 0 for none. None while the size is not known yet. |
runValue | How many bricks in a row point in the current direction, this bar's bricks included. None until the first brick. |
reversalValue | True on the bar whose bricks turned the direction (not on the very first brick). False otherwise. |
sizeValue | The brick size in price units, fixed for the run. None while the ATR warms up. |
When values are known
Bricks form at the close of the bar whose close reaches them and never change afterwards. With mode "atr" nothing forms before the ATR is known (atr_period + 1 bars); the bar that fixes the size is the anchor and makes no brick itself.
Limits
- Built from bar closes, not ticks: a move that reverses inside one bar leaves no brick, and on a higher timeframe fewer bricks form than on a tick chart.
- The ATR size is measured once at the start, so it depends on where the run starts and does not follow later changes in volatility.
- Brick levels are not prices that traded at that moment. Orders still fill at the real bid and ask of the next bar.
- A plugin indicator is not drawn on the chart and is not available in Blocks, Pine, Rust or C#; it runs on the run's own instrument only.