
## Strategy Overview
This strategy is a non-repainting quantitative trading system based on Renko chart emulation that solves the repainting problem found in traditional Renko strategies by simulating Renko brick behavior on standard time-based charts. The strategy uses fixed-size price bricks to filter market noise, focusing only on meaningful price movements while ensuring historical signals remain unchanged. This strategy is particularly suitable for trend following and trend reversal trading, making trading decisions by comparing brick direction changes through multiple steps.
Key features: - Implements non-repainting Renko effects on time-based charts - Identifies trend reversals using brick direction changes - Multi-step verification mechanism to improve signal quality - Graphical display of brick formation process - Stable backtesting results consistent with real-time trading performance
The core principle of this strategy is to implement Renko brick functionality on a standard time-based chart while solving the repainting problem found in traditional Renko charts. The specific working principles are as follows:
Parameter Configuration & Initialization:
brickSize: Defines the brick size, determining how much price must move to form a new brickrenkoPrice: Stores the closing price of the last completed Renko brickprevRenkoPrice: Stores the price level of the previous Renko brickbrickDir: Tracks the direction of bricks (1=up, -1=down)newBrick: A boolean flag indicating whether a new brick has been formedbrickStart: Stores the bar index at which the current brick startedNon-Repainting Renko Brick Identification:
Renko Visualization on Time-Based Charts:
Multi-Step Trend Reversal Detection:
After in-depth code analysis, this strategy demonstrates the following significant advantages:
Solves the Repainting Problem:
Noise Filtering and Clear Trend Identification:
Multi-Step Signal Verification:
brickDir[brickSize] with the current brickDir and historical price level relationshipsVisual Trading Foundation:
Flexibility and Customizability:
Despite solving the repainting problem, the following risk factors still exist:
Signal Delay Risk:
Brick Size Selection Risk:
Trend Reversal False Signal Risk:
Drawdown Risk:
Computational Resource Risk:
Based on code analysis, here are several key optimization directions for this strategy:
Dynamic Brick Size Optimization:
Add Trading Filters:
Improve Stop Loss and Profit Taking Mechanisms:
strategy.exit() commands, setting stop loss points based on ATR or brick sizeOptimize Multi-Step Verification Mechanism:
brickSize multiples to compare historical bricksImprove Visualization and Alert Systems:
label.new() and alert() functions to enhance user experienceThe Multi-Step Non-Repainting Renko Emulation Trend Reversal Quantitative Trading Strategy successfully addresses the repainting problem in traditional Renko strategies, enabling traders to apply Renko logic on standard time-based charts while maintaining the stability of historical signals. The strategy identifies trend reversals through a multi-step verification mechanism, improving signal quality, and visually displays market structure through graphical representation.
The main advantages of the strategy include solving the repainting problem, filtering market noise, multi-level signal verification, and intuitive graphical representation. However, risks still exist, including signal delays, brick size selection, and false signals. Future optimizations can be achieved by implementing dynamic brick sizes, adding trading filters, improving stop loss mechanisms, optimizing verification steps, and enhancing visualization systems.
This approach, which combines the advantages of Renko charts while avoiding their drawbacks, is particularly suitable for trend following and trend reversal trading strategies, providing traders with a reliable technical analysis tool that can deliver stable live performance while maintaining backtesting accuracy.
//@version=5
strategy("Non-Repainting Renko Emulation Strategy [PineIndicators]", overlay=true, calc_on_every_tick=false, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500, initial_capital = 10000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_value = 0.01, slippage = 2)
// Parameter: Brick-Größe (z.B. 10 Punkte)
brickSize = input.float(3.0, "Brick Size", step=0.1)
// Persistente Variablen
var float renkoPrice = na // Aktueller Renko-Level (Schlusswert des letzten Bricks)
var float prevRenkoPrice = na // Vorheriger Renko-Level (für Box-Berechnung)
var int brickDir = 0 // 1 = Aufwärts, -1 = Abwärts
var bool newBrick = false // Signalisiert, dass ein neuer Brick abgeschlossen wurde
var int brickStart = bar_index // Beginn des aktuellen Bricks (x-Achse)
// Berechnungen nur auf abgeschlossenen Candles
if barstate.isconfirmed
newBrick := false
// Initialisierung: Beim ersten Candle setzen wir den Renko-Level
if na(renkoPrice)
renkoPrice := close
brickStart := bar_index
// Berechne die Differenz zum letzten Renko-Level
diff = close - renkoPrice
// Prüfen, ob der Unterschied mindestens der Brick-Größe entspricht
if math.abs(diff) >= brickSize
// Anzahl kompletter Bricks (kann > 1 sein)
numBricks = math.floor(math.abs(diff) / brickSize)
prevRenkoPrice := renkoPrice
// Aktualisieren des Renko-Levels
renkoPrice := renkoPrice + numBricks * brickSize * math.sign(diff)
// Brick-Richtung (konvertiere math.sign-Ergebnis in int)
brickDir := int(math.sign(diff))
newBrick := true
// Bestimme die obere und untere Grenze des abgeschlossenen Bricks:
lowLevel = brickDir == 1 ? prevRenkoPrice : renkoPrice
highLevel = brickDir == 1 ? renkoPrice : prevRenkoPrice
// Setze den Start für den nächsten Brick
brickStart := bar_index
// Handelslogik: Einstieg/Ausstieg nur, wenn ein neuer Brick abgeschlossen wurde
if barstate.isconfirmed and newBrick
// Bei Aufwärts-Brick: Long-Signal
if brickDir[brickSize] < brickDir and renkoPrice[brickSize] < renkoPrice[brickSize*2] and renkoPrice < renkoPrice[brickSize] and renkoPrice[brickSize*2] < renkoPrice[brickSize*3] and strategy.position_size <= 0
// Bestehende Short-Position schließen, falls vorhanden
strategy.entry("Long", strategy.long)
// Bei Abwärts-Brick: Short-Signal
else if brickDir[brickSize] > brickDir and renkoPrice[brickSize] > renkoPrice[brickSize*2] and renkoPrice > renkoPrice[brickSize] and renkoPrice[brickSize*2] > renkoPrice[brickSize*3] and strategy.position_size >= 0
// Bestehende Long-Position schließen, falls vorhanden
strategy.entry("Short", strategy.short)
if barstate.isconfirmed and newBrick
if brickDir[brickSize] < brickDir
strategy.close("Short")
else if brickDir[brickSize] > brickDir
strategy.close("Long")