OPEN-SOURCE SCRIPT

CRT Engine [vault]

2 095
CRT Engine [vault]

CRT Engine [vault] is a complete Candle Range Theory toolkit built around one idea: the higher timeframe candle sets the range, the lower timeframe shows you how that range gets manipulated and delivered. The script tracks the HTF range, detects sweeps of the previous high or low, confirms the shift with an order block or a CISD, and follows the model until it either reaches its target or gets invalidated. Around that core it adds HTF fair value gaps, previous period highs and lows, SMT divergence, multi timeframe moving averages and a compact dashboard, all sharing one color palette so the chart stays readable.


HOW THE CRT MODEL WORKS

Every new HTF candle opens a new range. Its high and low are tracked live on the chart timeframe. When the HTF candle closes, the script compares it to the previous HTF candle:

• Sweep of the high: the candle traded above the previous high and closed back below it. Bias flips to bearish, the previous low becomes the target.
• Sweep of the low: the candle traded below the previous low and closed back above it. Bias flips to bullish, the previous high becomes the target.
• Double purge: both sides were taken in the same candle. Bias is decided by the candle direction (bullish close = bullish bias) and the sweep is labeled D-Purge.

From that point the model is Active. It becomes Success when price reaches the target side of the previous range and Invalidated when price breaks back through the swept level. Status is reflected on the range box border and on the HTF candle panel.


MODEL 1 VS MODEL 2

Model 1 is the faster version. The sweep is detected in real time on the chart timeframe, not only at HTF close. As soon as price breaches the previous high or low and closes back inside, the sweep line, the target line and an order block line are drawn. The order block is the low of the candle that set the swept high (or the high of the candle that set the swept low). If price later trades through the sweep level, everything is cleared and the model resets.

Model 2 is the confirmation version. After the sweep candle closes, the script looks back through the consecutive same-direction candles that built the manipulation leg and stores the opening price of that series. A CISD (change in state of delivery) prints when a chart timeframe candle closes through that level. The sweep candle is labeled C1 and the CISD candle is labeled C3, matching the classic three candle CRT structure.

A bias filter lets you run the model long only, short only, or neutral.


TIMEFRAME PAIRING

Auto mode picks the HTF from the chart timeframe: 1m to 15m, 3m to 30m, 5m to 1H, 15m to 4H, 1H to 1D, 4H to 1W, 1D to 1M. Presets are available for 1H-1D, 4H-1W, 1D-1M and 1W-3M, and a custom HTF can be set for anything else. The script validates that the HTF is higher than the chart timeframe and stays idle otherwise.


HTF CANDLE PANEL

On the right side of the chart the script draws the last few HTF candles as mini candles with wicks. Above them sits the HTF label with a live countdown to the next close, below them the current model bias. Sweeps between panel candles are marked with a small line and a sweep label, and the candle borders change color with the model status (neutral while active, bull color on success, bear color on invalidation). Offset, spacing, width and candle count are adjustable.


HTF FAIR VALUE GAPS

Fair value gaps are detected on a higher timeframe, either automatically chosen from the chart timeframe or set manually. Each gap is drawn as a box that starts at the close of the first candle of the three candle pattern, which is where the imbalance actually forms, and extends to the right with an optional midline and a label showing the HTF. A gap is removed once the HTF candle closes through it. You can cap how many gaps stay on the chart.


HTF LEVELS

Previous day, week, month, quarter and year highs and lows, with the previous open as an optional third line. Lines start at the bar where the level was formed and stop exactly where price first touches them, so a mitigated level is still visible but no longer projected forward. Labels use the PDH / PDL / PWH / PWL convention. Line style, width and label size are shared across all timeframes.


SMT DIVERGENCE

The script compares the chart symbol with a correlated instrument and flags divergence in two ways: at HTF close (one symbol made a higher high while the other did not, with a matching candle direction) and on chart timeframe pivots (a new higher high on the chart while the paired symbol printed a lower high, or the mirror for lows). Divergence is drawn as a line between the two swing points with the pair name as a label. Auto pairing covers index futures (NQ, ES, YM, RTY and their micros), CFD indices, major and cross forex pairs, currency futures, gold, silver, oil products and BTC/ETH. A manual pair can be set for anything else. Optionally only the latest bullish and bearish SMT are kept.


MOVING AVERAGES

Five configurable moving averages (SMA, EMA, RMA, WMA, HMA, VWMA), each with its own length and timeframe. Lines are hidden by default and can be toggled with one switch. When enabled, all lines automatically hide once the chart timeframe is higher than the highest MA timeframe in use, so a 15m EMA never gets drawn on a daily chart. The dashboard trend rows keep reading the first three MAs whether the lines are visible or not.


DASHBOARD

A small table showing the chart and HTF pairing, the active model and bias filter, the current bias, an aggregated MA trend (bullish, bearish or mixed) with per-MA arrows, the SMT pair in use and the date. Position and text size are configurable.


COLOR SCHEMES

Seven schemes, each defining the bull, bear, neutral, text and accent colors that every element on the chart uses:

• Vault Dark: teal and rose on a dark background, the default
• Light: near black text and lines with blue and red accents, made for white charts
• Midnight: blue and pink
• Neon: bright green and magenta
• Ember: orange and red
• Mono: greyscale
• Custom: set all five colors yourself

Box transparency is controlled with a single slider.


ALERTS

• Model formed: a new HTF candle closed and the model state was evaluated
• Sweep: a sweep of the previous high or low was detected
• Double purge: both sides of the previous range were taken
• Model success: the target was reached
• Model invalidated: the sweep level was broken


NOTES

The model logic does not repaint. HTF data is requested without lookahead and the Model 1 real time sweep is confirmed on candle close. Drawings such as the panel, the labels and the level extensions are repositioned on the last bar for display only.

The script is a context and structure tool. It does not generate trade signals and nothing in it should be treated as financial advice.



Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.