OPEN-SOURCE SCRIPT
업데이트됨

CRT Pattern

313
CRT Pattern automatically detects and manages CRT (Candle Range Theory) setups on a user-selected higher timeframe, displaying all key structural elements while providing a comprehensive set of alerts for discretionary trading, automation, and Study-on-Study integrations.

The indicator automatically identifies:
• Range Candle
• Inside Candles
• Sweep Candle
• CRT confirmation
• Discount Zone
• All major structural levels (CRH, CRL, CRM, SH/SL, and Discount Border)

Once a pattern is confirmed, the indicator continues to track it until its target is reached or its structure becomes invalid.

How the Indicator Works

The detection process begins by searching for a Range Candle.
A candle qualifies as a Range Candle only if both of the following conditions are met:
• Its body represents at least the specified percentage of the candle's total range.
• Its size exceeds the user-defined ATR threshold.

After a valid Range Candle is found, the indicator monitors one of three possible outcomes:
• One or more Inside Candles are formed.
• A Sweep Candle confirms the CRT pattern.
• The potential setup is invalidated before confirmation.

Once the Sweep Candle closes, the CRT is considered confirmed, and all structural levels and zones are automatically plotted on the chart. From that point forward, the indicator does not recalculate the pattern. Instead, it simply manages the already established structure until the pattern is completed or invalidated.

Pattern Components

Once a CRT is confirmed, the indicator displays every key element of its structure.

Range Candle
The first candle of the pattern that defines the entire trading range. It is highlighted with a colored box:
• Green for a bullish Range Candle.
• Red for a bearish Range Candle.

The CRH, CRL, and CRM levels are all derived from this candle.

Inside Candle
Candles whose entire range remains inside the Range Candle. These candles are displayed as gray boxes. There is no limit to the number of Inside Candles that may appear before the Sweep Candle.

Sweep Candle
The candle that confirms the CRT pattern.

For a Long CRT, the Sweep Candle:
• trades below the Range Candle's low;
• closes back above CRL.

For a Short CRT, it:
• trades above the Range Candle's high;
• closes back below CRH.

A CRT is considered confirmed only after the Sweep Candle has closed.

Like the Range Candle, the Sweep Candle is highlighted according to its direction:
• Green if it closes bullish.
• Red if it closes bearish.

CRH (Candle Range High)
The upper boundary of the Range Candle.
Displayed as a red dotted horizontal line.

CRL (Candle Range Low)
The lower boundary of the Range Candle.
Displayed as a green dotted horizontal line.

CRM (Candle Range Mid)
The midpoint of the Range Candle.
It is calculated as the midpoint between the candle's High and Low.
Displayed as a gray dotted horizontal line.

SH / SL
The extreme price of the Sweep Candle.
• SH (Sweep High) is used for Short CRTs.
• SL (Sweep Low) is used for Long CRTs.
Displayed as the corresponding dotted horizontal line.

Discount Border
The boundary of the Discount Zone.

Its position depends on the selected Discount Border setting and can be based on one of the following reference levels:
• CRM
• CRH/CRL
• SH/SL
• Sweep Open
• Sweep Close

It is displayed as a yellow dotted horizontal line.

Discount Zone
The area between the Sweep level and the selected Discount Border.
This zone represents the preferred area for evaluating potential entries after a CRT has been confirmed.
• Green for Long CRTs.
• Red for Short CRTs.

Pattern Lifecycle

Once a CRT has been confirmed, the indicator continues tracking it until one of the following conditions occurs.

1. Target Reached
• A Long CRT is considered complete when price reaches CRH.
• A Short CRT is considered complete when price reaches CRL.
Once the target has been reached, the pattern is no longer updated.

2. Sweep Failure
• A Long CRT becomes invalid if a candle on the selected higher timeframe closes below SL.
• A Short CRT becomes invalid if a candle on the selected higher timeframe closes above SH.
Important: Sweep failure is confirmed only by the close of the selected higher timeframe candle. Intrabar breaks or wick penetrations do not invalidate the pattern.

3. Completed Pattern Display
The behavior of completed patterns is controlled by the Show Only Active Patterns setting.
• Enabled — completed or invalidated patterns are automatically removed from the chart.
• Disabled — the pattern stops updating but remains on the chart as historical reference.

Key Features

• Designed to operate on a chart timeframe lower than the selected HTF.
• The selected Range Candle timeframe must always be higher than the current chart timeframe.
• All structural calculations are based exclusively on candles from the selected higher timeframe.
• Multiple active CRT patterns can be tracked simultaneously.
• Once confirmed, every structural level remains fixed for the lifetime of the pattern.
• The indicator does not repaint confirmed patterns. After confirmation, only the graphical extensions (lines and zones) continue extending to the latest bar while the underlying structure remains unchanged.

Alerts

The indicator provides a complete set of alerts for discretionary trading, automation, and custom workflows.

All alerts can be used with:
• Standard TradingView Alerts
• Webhooks
• Automated trading systems
• Study-on-Study integrations
• Custom indicators and strategies

Pattern Alerts

New CRT Pattern
Triggers whenever any new CRT (Long or Short) is confirmed.

New CRT Long Pattern
Triggers only when a Long CRT is confirmed.

New CRT Short Pattern
Triggers only when a Short CRT is confirmed.

Discount Zone Alerts

Discount Long
Active while the closing price remains inside the Long Discount Zone. Condition:
Pine Script®
SL ≤ Close ≤ Discount Border

This is a state-based alert rather than a one-time event. As long as the closing price remains inside the Long Discount Zone, the alert condition evaluates to true.

Discount Short
Active while the closing price remains inside the Short Discount Zone. Condition:
Pine Script®
Discount Border ≤ Close ≤ SH

Like the Long version, this is a state-based alert rather than a single trigger.

Structural Level Cross Alerts

The following alerts detect when the closing price crosses one of the CRT structural levels.
Each alert is evaluated using bar closes only.

CRL Up Cross
Triggers when the closing price crosses CRL from below.

CRL Down Cross
Triggers when the closing price crosses CRL from above.

CRH Up Cross
Triggers when the closing price crosses CRH from below.

CRH Down Cross
Triggers when the closing price crosses CRH from above.

CRM Up Cross
Triggers when the closing price crosses CRM from below.

CRM Down Cross
Triggers when the closing price crosses CRM from above.

SH/SL Up Cross
Triggers when the closing price crosses the Sweep level from below.
• SL is used for Long CRTs.
• SH is used for Short CRTs.

SH/SL Down Cross
Triggers when the closing price crosses the Sweep level from above.
• SL is used for Long CRTs.
• SH is used for Short CRTs.

Discount Border Up Cross
Triggers when the closing price crosses the selected Discount Border from below.

The actual level depends on the Discount Border setting:
• CRM
• CRH / CRL
• SH / SL
• Sweep Open
• Sweep Close

Discount Border Down Cross
Triggers when the closing price crosses the selected Discount Border from above.
The reference level depends on the current Discount Border configuration.

Important Notes About Cross Alerts

All crossing alerts are calculated using the closing price only. If price temporarily breaks a level with its wick but closes on the same side of that level, no crossing alert will be generated. This behavior intentionally filters out intrabar noise and provides consistent, non-ambiguous signals for discretionary trading and automated systems.

Study-on-Study Compatibility

Every alert condition exposed by the indicator can also be used through TradingView's Study-on-Study functionality. This allows CRT Pattern to serve as a structural filter for other indicators and strategies.

Typical use cases include:
• allowing entries only while price is inside a Discount Zone;
• confirming entries after crossing CRH, CRL, CRM, SH/SL, or the selected Discount Border;
• filtering signals based on the presence of an active Long or Short CRT;
• combining CRT structure with proprietary entry or exit logic.

Since all structural levels become fixed once a pattern is confirmed, Study-on-Study integrations receive stable, non-repainting signals throughout the lifetime of the pattern.

Settings

Range Settings

Timeframe
Specifies the higher timeframe (HTF) used for CRT detection. The selected timeframe must be higher than the current chart timeframe. All pattern detection and structural calculations are performed using candles from this timeframe.

Body Min. %
Defines the minimum percentage of the candle's body relative to its total range for a candle to qualify as a Range Candle. Higher values restrict detection to stronger, more impulsive candles, while lower values allow a broader range of setups.

Candle Min. Size
Defines the minimum size of a Range Candle expressed in ATR multiples. This filter helps eliminate insignificant or low-volatility ranges. Increasing the value results in fewer but generally stronger setups.

Max. Pullback %
Defines the maximum allowed pullback before the Sweep Candle forms. If price retraces beyond the specified percentage of the Range Candle before the pattern is confirmed, the potential CRT is considered invalid and discarded.

Discount Border
Selects which structural level is used as the boundary of the Discount Zone.

Available options:
• Range Middle (CRM) – the midpoint of the Range Candle.
• Range High / Low (CRH / CRL) – the opposite boundary of the Range Candle.
• Sweep High / Low (SH / SL) – the extreme of the Sweep Candle.
• Sweep Open (SO) – the opening price of the Sweep Candle.
• Sweep Close (SC) – the closing price of the Sweep Candle.

Changing this setting automatically updates both the displayed Discount Zone and the corresponding Discount Border alerts.

Visual Settings

Show Only Active Patterns
Controls how completed patterns are displayed.
• Enabled – completed or invalidated CRTs are automatically removed from the chart.
• Disabled – completed patterns remain visible as historical reference but are no longer updated.

Color Settings
Every graphical element can be customized independently, including:
• Bullish Range Candle
• Bearish Range Candle
• Inside Candles
• CRH
• CRL
• CRM
• SH
• SL
• Discount Border
• Long Discount Zone
• Short Discount Zone

This makes it easy to integrate the indicator with any TradingView chart theme.

Design Philosophy

CRT Pattern is designed to provide an objective and consistent visualization of CRT market structure without requiring manual drawing or interpretation. Every stage of the pattern—from detection to completion—is handled automatically. Once confirmed, all structural levels remain fixed, ensuring that the indicator provides stable, non-repainting references throughout the lifetime of the pattern.

The indicator can be used as:
• a standalone market structure analysis tool;
• a discretionary trading aid;
• a signal source for automated systems;
• or a structural component within more advanced Study-on-Study workflows.

Final Notes

• Supports multiple active CRT patterns simultaneously.
• Works on any market and any chart timeframe, provided the selected HTF is higher than the chart timeframe.
• Uses only confirmed higher timeframe data for pattern confirmation.
• Confirmed CRT patterns never repaint.
• All structural alerts are based exclusively on bar closing prices, ensuring deterministic and reliable behavior for both manual trading and automation.
릴리즈 노트
Remove comment

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.