OPEN-SOURCE SCRIPT
G-Score | NAL

1. Overview
G-Score | NAL is a volatility-adjusted Z-Score regime indicator built from two main components: a smoothed price Z-Score and an adaptive GARCH-based volatility Z-Score.
The indicator does not use fixed overbought or oversold levels. Instead, it builds dynamic thresholds from the current volatility structure of the market. Price is then measured against those volatility-derived boundaries to determine whether the market is entering a bullish or bearish statistical regime.
2. Calculation
The indicator starts by estimating volatility through a GARCH-style process. It calculates log returns from the selected source, converts those returns into squared variance, and then compares short-term variance behavior against a realized variance baseline.
Pine Script®
The model then searches through possible beta and gamma coefficients to find weights that better fit the recent variance environment. These optimized coefficients are used to build a GARCH variance estimate from three components: long-run variance, recent shock variance, and lagged variance.
Pine Script®
The final GARCH volatility value is created by taking the square root of the projected variance. This produces the volatility engine used later in the threshold system.
The indicator then calculates two separate Z-Scores. The first is a price Z-Score, measuring where price is relative to its own mean and deviation. The second is a volatility Z-Score, measuring where GARCH volatility is relative to its own historical distribution.
Both values are smoothed with a Jurik-style moving average to reduce noise while keeping the response relatively fast.
The volatility Z-Score is then mirrored into positive and negative boundaries. This creates dynamic upper and lower thresholds that expand and contract with the current volatility regime.
The final signal compares the smoothed price Z-Score against those adaptive volatility thresholds. A bullish state triggers when price strength expands above the upper volatility boundary. A bearish state triggers when price weakness falls below the lower volatility boundary. When price remains inside the volatility envelope, the previous regime is held.
3. Key Features
4. Use
G-Score is designed to identify when price begins separating from its normal statistical range after accounting for the current volatility environment. A move above the upper threshold reflects bullish statistical expansion, while a move below the lower threshold reflects bearish statistical expansion.
The strength of the indicator comes from the relationship between price displacement and volatility regime. Rather than treating every Z-Score reading the same, it lets volatility define the boundary that price must break.
This indicator is best used as a specialized module within a complete strategy framework. Its role is to isolate a specific statistical layer of market behavior, where price expansion is evaluated through the lens of adaptive volatility. The full value comes from how this regime signal is integrated into a broader process for timing, structure, and risk.
G-Score | NAL is a volatility-adjusted Z-Score regime indicator built from two main components: a smoothed price Z-Score and an adaptive GARCH-based volatility Z-Score.
The indicator does not use fixed overbought or oversold levels. Instead, it builds dynamic thresholds from the current volatility structure of the market. Price is then measured against those volatility-derived boundaries to determine whether the market is entering a bullish or bearish statistical regime.
2. Calculation
The indicator starts by estimating volatility through a GARCH-style process. It calculates log returns from the selected source, converts those returns into squared variance, and then compares short-term variance behavior against a realized variance baseline.
The model then searches through possible beta and gamma coefficients to find weights that better fit the recent variance environment. These optimized coefficients are used to build a GARCH variance estimate from three components: long-run variance, recent shock variance, and lagged variance.
The final GARCH volatility value is created by taking the square root of the projected variance. This produces the volatility engine used later in the threshold system.
The indicator then calculates two separate Z-Scores. The first is a price Z-Score, measuring where price is relative to its own mean and deviation. The second is a volatility Z-Score, measuring where GARCH volatility is relative to its own historical distribution.
Both values are smoothed with a Jurik-style moving average to reduce noise while keeping the response relatively fast.
The volatility Z-Score is then mirrored into positive and negative boundaries. This creates dynamic upper and lower thresholds that expand and contract with the current volatility regime.
The final signal compares the smoothed price Z-Score against those adaptive volatility thresholds. A bullish state triggers when price strength expands above the upper volatility boundary. A bearish state triggers when price weakness falls below the lower volatility boundary. When price remains inside the volatility envelope, the previous regime is held.
3. Key Features
- Adaptive GARCH-style volatility engine.
- Price Z-Score measured against volatility-derived thresholds.
- Dynamic upper and lower boundaries instead of fixed levels.
- Jurik-style smoothing for both price and volatility components.
- State-based candle coloring, background regime coloring, threshold fills, and transition labels.
- Designed to capture statistical expansion when price moves outside its volatility-adjusted structure.
4. Use
G-Score is designed to identify when price begins separating from its normal statistical range after accounting for the current volatility environment. A move above the upper threshold reflects bullish statistical expansion, while a move below the lower threshold reflects bearish statistical expansion.
The strength of the indicator comes from the relationship between price displacement and volatility regime. Rather than treating every Z-Score reading the same, it lets volatility define the boundary that price must break.
This indicator is best used as a specialized module within a complete strategy framework. Its role is to isolate a specific statistical layer of market behavior, where price expansion is evaluated through the lens of adaptive volatility. The full value comes from how this regime signal is integrated into a broader process for timing, structure, and risk.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.