OPEN-SOURCE SCRIPT
Cycle & Flow Indicator - D_Quant

Cycle & Flow Architecture (CFA) | Multi-Factor Regime Analysis
Overview
The Cycle & Flow Architecture (CFA) is a trend-following visualization engine that utilizes a triple-confirmation "Voting Mechanism" to identify market regimes. Rather than relying on a single lagging indicator, the CFA aggregates Cyclical Momentum, Directional Bias, and Volume Flow from the Daily timeframe to provide a unified consensus signal on your current chart.
The goal of this script is to filter market noise by requiring a quantitative agreement between three non-correlated mathematical models before a "Regime Change" is visualized.
The Quantitative Logic
The core of the CFA is its Aggregation Engine, which calculates a normalized Quant Score ranging from -1.0 to +1.0. The engine polls three distinct components:
Schaff Trend Cycle (STC): This component identifies the cyclical nature of price. It applies a double-smoothed stochastic process to a MACD line. In this script, the STC contributes a bullish signal when the cycle is above 25 and a bearish signal when the cycle is below 75 and falling.
Parabolic SAR (PSAR):Used as a rigid directional filter. It calculates the "Stop and Reverse" points, if the price is above the PSAR, it contributes a +1 to the consensus, if below, a -1.
Ease of Movement (EOM): This is the volume-validation component. It analyzes the relationship between price change and volume. A positive EOM suggests price is moving up on light resistance (conviction), while negative EOM suggests easy downward movement.
How it Works: The Voting Mechanism
The script calculates these three values on the Daily (D) timeframe using request.security to ensure higher-timeframe confluence.
Bullish Regime: Triggered when the average score exceeds the Bullish Threshold (Default: 0.2).
Bearish Regime: Triggered when the average score falls below the Bearish Threshold (Default: -0.2).
Neutral Regime: When the components disagree or the scores hover near zero, the engine renders a "Grey" noise state, signaling a high-probability "sit on hands" environment.
How to Use
The Ghost Cloud: The central Hull Moving Average (HMA 20) acts as the baseline. The "cloud" fills between this baseline and the price, colored by the current Score.
Volatility Extensions: The script plots ATR-based bands (14-period) that only appear during confirmed regimes. In a Bullish regime, the upper band appears, in a Bearish regime, the lower.
Trade Execution: Traders typically look for the "Bullish/Bearish Start" alerts to signal the beginning of a new regime and use the "Grey" neutral zones to tighten stop-losses or exit positions.
Settings
Thresholds: Increase the Bullish/Bearish thresholds (e.g., to 0.5) to require more stringent agreement between the STC, PSAR, and EOM.
Timeframe Note: The calculations are hardcoded to the Daily timeframe to provide a "North Star" directional bias regardless of whether you are viewing the 15m or 4h chart.
Disclaimer: This tool is for educational and analytical purposes only. Quantitative models represent mathematical probabilities, not guarantees.
© D_QUANT
Overview
The Cycle & Flow Architecture (CFA) is a trend-following visualization engine that utilizes a triple-confirmation "Voting Mechanism" to identify market regimes. Rather than relying on a single lagging indicator, the CFA aggregates Cyclical Momentum, Directional Bias, and Volume Flow from the Daily timeframe to provide a unified consensus signal on your current chart.
The goal of this script is to filter market noise by requiring a quantitative agreement between three non-correlated mathematical models before a "Regime Change" is visualized.
The Quantitative Logic
The core of the CFA is its Aggregation Engine, which calculates a normalized Quant Score ranging from -1.0 to +1.0. The engine polls three distinct components:
Schaff Trend Cycle (STC): This component identifies the cyclical nature of price. It applies a double-smoothed stochastic process to a MACD line. In this script, the STC contributes a bullish signal when the cycle is above 25 and a bearish signal when the cycle is below 75 and falling.
Parabolic SAR (PSAR):Used as a rigid directional filter. It calculates the "Stop and Reverse" points, if the price is above the PSAR, it contributes a +1 to the consensus, if below, a -1.
Ease of Movement (EOM): This is the volume-validation component. It analyzes the relationship between price change and volume. A positive EOM suggests price is moving up on light resistance (conviction), while negative EOM suggests easy downward movement.
How it Works: The Voting Mechanism
The script calculates these three values on the Daily (D) timeframe using request.security to ensure higher-timeframe confluence.
Bullish Regime: Triggered when the average score exceeds the Bullish Threshold (Default: 0.2).
Bearish Regime: Triggered when the average score falls below the Bearish Threshold (Default: -0.2).
Neutral Regime: When the components disagree or the scores hover near zero, the engine renders a "Grey" noise state, signaling a high-probability "sit on hands" environment.
How to Use
The Ghost Cloud: The central Hull Moving Average (HMA 20) acts as the baseline. The "cloud" fills between this baseline and the price, colored by the current Score.
Volatility Extensions: The script plots ATR-based bands (14-period) that only appear during confirmed regimes. In a Bullish regime, the upper band appears, in a Bearish regime, the lower.
Trade Execution: Traders typically look for the "Bullish/Bearish Start" alerts to signal the beginning of a new regime and use the "Grey" neutral zones to tighten stop-losses or exit positions.
Settings
Thresholds: Increase the Bullish/Bearish thresholds (e.g., to 0.5) to require more stringent agreement between the STC, PSAR, and EOM.
Timeframe Note: The calculations are hardcoded to the Daily timeframe to provide a "North Star" directional bias regardless of whether you are viewing the 15m or 4h chart.
Disclaimer: This tool is for educational and analytical purposes only. Quantitative models represent mathematical probabilities, not guarantees.
© D_QUANT
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.