OPEN-SOURCE SCRIPT
PhenLabs - Market Fluid Dynamics

📊 Market Fluid Dynamics - [PhenLabs]
Version: PineScript™ v6
📌 Description
The Market Fluid Dynamics - Phen indicator is a new thinking regarding market analysis by modeling price action, volume, and volatility using a fluid system. It attempts to offer traders control over more profound market forces, such as momentum (speed), resistance (thickness), and buying/selling pressure. By visualizing such dynamics, the script allows the traders to decide on the prevailing market flow, its power, likely continuations, and zones of calmness and chaos, and thereby allows improved decision-making.
This measure avoids the usual difficulty of reconciling multiple, often contradictory, market indications by including them within a single overarching model. It moves beyond traditional binary indicators by providing a multi-dimensional view of market behavior, employing fluid dynamic analogs to describe complex interactions in an accessible manner.
🚀 Points of Innovation
🔧 Core Components
🔥 Key Features
🎨 Visualization

📖 Usage Guidelines
Setting Categories
✅ Best Use Cases
⚠️ Limitations
💡 What Makes This Unique
🔬 How It Works
Version: PineScript™ v6
📌 Description
The Market Fluid Dynamics - Phen indicator is a new thinking regarding market analysis by modeling price action, volume, and volatility using a fluid system. It attempts to offer traders control over more profound market forces, such as momentum (speed), resistance (thickness), and buying/selling pressure. By visualizing such dynamics, the script allows the traders to decide on the prevailing market flow, its power, likely continuations, and zones of calmness and chaos, and thereby allows improved decision-making.
This measure avoids the usual difficulty of reconciling multiple, often contradictory, market indications by including them within a single overarching model. It moves beyond traditional binary indicators by providing a multi-dimensional view of market behavior, employing fluid dynamic analogs to describe complex interactions in an accessible manner.
🚀 Points of Innovation
- Integrated Fluid Dynamics Model: Combines velocity, viscosity, pressure, and turbulence into a single indicator.
- Normalized Metrics: Uses ATR and other normalization techniques for consistent readings across different assets and timeframes.
- Dynamic Flow Visualization: Main flow line changes color and intensity based on direction and strength.
- Turbulence Background: Visually represents market stability with a gradient background, from calm to turbulent.
- Comprehensive Dashboard: Provides an at-a-glance summary of key fluid dynamic metrics.
- Multi-Layer Smoothing: Employs several layers of EMA smoothing for a clearer, more responsive main flow line.
🔧 Core Components
- Velocity Component: Measures price momentum (first derivative of price), normalized by ATR. It indicates the speed and direction of price changes.
- Viscosity Component: Represents market resistance to price changes, derived from ATR relative to its historical average. Higher viscosity suggests it’s harder for prices to move.
- Pressure Component: Quantifies the force created by volume and price range (close - open), normalized by ATR. It reflects buying or selling pressure.
- Turbulence Detection: Calculates a Reynolds number equivalent to identify market stability, ranging from laminar (stable) to turbulent (chaotic).
- Main Flow Indicator: Combines the above components, applying sensitivity and smoothing, to generate a primary signal of market direction and strength.
🔥 Key Features
- Advanced Smoothing Algorithm: Utilizes multiple EMA layers on the raw flow calculation for a fluid and responsive main flow line, reducing noise while maintaining sensitivity.
- Gradient Flow Coloring: The main flow line dynamically changes color from light to deep blue for bullish flow and light to deep red for bearish flow, with intensity reflecting flow strength. This provides an immediate visual cue of market sentiment and momentum.
- Turbulence Level Background: The chart background changes color based on calculated turbulence (from calm gray to vibrant orange), offering an intuitive understanding of market stability and potential for erratic price action.
- Informative Dashboard: A customizable on-screen table displays critical metrics like Flow State, Flow Strength, Market Viscosity, Turbulence, Pressure Force, Flow Acceleration, and Flow Continuity, allowing traders to quickly assess current market conditions.
- Configurable Lookback and Sensitivity: Users can adjust the base lookback period for calculations and the sensitivity of the flow to viscosity, tailoring the indicator to different trading styles and market conditions.
- Alert Conditions: Pre-defined alerts for flow direction changes (positive/negative crossover of zero line) and detection of high turbulence states.
🎨 Visualization
- Main Flow Line: A smoothed line plotted below the main chart, colored blue for bullish flow and red for bearish flow. The intensity of the color (light to dark) indicates the strength of the flow. This line crossing the zero line can signal a change in market direction.
- Zero Line: A dotted horizontal line at the zero level, serving as a baseline to gauge whether the market flow is positive (bullish) or negative (bearish).
- Turbulence Background: The indicator pane’s background color changes based on the calculated turbulence level. A calm, almost transparent gray indicates low turbulence (laminar flow), while a more vibrant, semi-transparent orange signifies high turbulence. This helps traders visually assess market stability.
- Dashboard Table: An optional table displayed on the chart, showing key metrics like ‘Flow State’, ‘Flow Strength’, ‘Market Viscosity’, ‘Turbulence’, ‘Pressure Force’, ‘Flow Acceleration’, and ‘Flow Continuity’ with their current values and qualitative descriptions (e.g., ‘Bullish Flow’, ‘Laminar (Stable)’).
📖 Usage Guidelines
Setting Categories
- Show Dashboard - Default: true; Range: true/false; Description: Toggles the visibility of the Market Fluid Dynamics dashboard on the chart. Enable to see key metrics at a glance.
- Base Lookback Period - Default: 14; Range: 5 - (no upper limit, practical limits apply); Description: Sets the primary lookback period for core calculations like velocity, ATR, and volume SMA. Shorter periods make the indicator more sensitive to recent price action, while longer periods provide a smoother, slower signal.
- Flow Sensitivity - Default: 0.5; Range: 0.1 - 1.0 (step 0.1); Description: Adjusts how much the market viscosity dampens the raw flow. A lower value means viscosity has less impact (flow is more sensitive to raw velocity/pressure), while a higher value means viscosity has a greater dampening effect.
- Flow Smoothing - Default: 5; Range: 1 - 20; Description: Controls the length of the EMA smoothing applied to the main flow line. Higher values result in a smoother flow line but with more lag; lower values make it more responsive but potentially noisier.
- Dashboard Position - Default: ‘Top Right’; Range: ‘Top Right’, ‘Top Left’, ‘Bottom Right’, ‘Bottom Left’, ‘Middle Right’, ‘Middle Left’; Description: Determines the placement of the dashboard on the chart.
- Header Size - Default: ‘Normal’; Range: ‘Tiny’, ‘Small’, ‘Normal’, ‘Large’, ‘Huge’; Description: Sets the text size for the dashboard header.
- Values Size - Default: ‘Small’; Range: ‘Tiny’, ‘Small’, ‘Normal’, ‘Large’; Description: Sets the text size for the metric values in the dashboard.
✅ Best Use Cases
- Trend Identification: Identifying the dominant market flow (bullish or bearish) and its strength to trade in the direction of the prevailing trend.
- Momentum Confirmation: Using the flow strength and acceleration to confirm the conviction behind price movements.
- Volatility Assessment: Utilizing the turbulence metric to gauge market stability, helping to adjust position sizing or avoid choppy conditions.
- Reversal Spotting: Watching for divergences between price and flow, or crossovers of the main flow line above/below the zero line, as potential reversal signals, especially when combined with changes in pressure or viscosity.
- Swing Trading: Leveraging the smoothed flow line to capture medium-term market swings, entering when flow aligns with the desired trade direction and exiting when flow weakens or reverses.
- Intraday Scalping: Using shorter lookback periods and higher sensitivity to identify quick shifts in flow and turbulence for short-term trading opportunities, particularly in liquid markets.
⚠️ Limitations
- Lagging Nature: Like many indicators based on moving averages and lookback periods, the main flow line can lag behind rapid price changes, potentially leading to delayed signals.
- Whipsaws in Ranging Markets: During periods of low volatility or sideways price action (high viscosity, low flow strength), the indicator might produce frequent buy/sell signals (whipsaws) as the flow oscillates around the zero line.
- Not a Standalone System: While comprehensive, it should be used in conjunction with other forms of analysis (e.g., price action, support/resistance levels, other indicators) and not as a sole basis for trading decisions.
- Subjectivity in Interpretation: While the dashboard provides quantitative values, the interpretation of “strong” flow, “high” turbulence, or “significant” acceleration can still have a subjective element depending on the trader’s strategy and risk tolerance.
💡 What Makes This Unique
- Fluid Dynamics Analogy: Its core strength lies in translating complex market interactions into an intuitive fluid dynamics framework, making concepts like momentum, resistance, and pressure easier to visualize and understand.
- Market View: Instead of focusing on a single aspect (like just momentum or just volatility), it integrates multiple factors (velocity, viscosity, pressure, turbulence) to provide a more comprehensive picture of market conditions.
- Adaptive Visualization: The dynamic coloring of the flow line and the turbulence background provide immediate, adaptive visual feedback that changes with market conditions.
🔬 How It Works
- Price Velocity Calculation: The indicator first calculates price velocity by measuring the rate of change of the closing price over a given ‘lookback’ period. The raw velocity is then normalized by the Average True Range (ATR) of the same lookback period. Normalization enables comparison of momentum between assets or timeframes by scaling for volatility. This is the direction and speed of initial price movement.
- Viscosity Calculation: Market ‘viscosity’ or resistance to price movement is determined by looking at the current ATR relative to its longer-term average (SMA of ATR over lookback * 2). The further the current ATR is above its average, the lower the viscosity (less resistance to price movement), and vice-versa. The script inverts this relationship and bounds it so that rising viscosity means more resistance.
- Pressure Force Measurement: A ‘pressure’ variable is calculated as a function of the ratio of current volume to its simple moving average, multiplied by the price range (close - open) and normalized by ATR. This is designed to measure the force behind price movement created by volume and intraday price thrusts. This pressure is smoothed by an EMA.
- Turbulence State Evaluation: A equivalent ‘Reynolds number’ is calculated by dividing the absolute normalized velocity by the viscosity. This is the proclivity of the market to move in a chaotic or orderly fashion. This ‘reynoldsValue’ is smoothed with an EMA to get the ‘turbulenceState’, which indicates if the market is laminar (stable), transitional, or turbulent.
- Main Flow Derivation: The ‘rawFlow’ is calculated by taking the normalized velocity, dampening its impact based on the ‘viscosity’ and user-input ‘sensitivity’, and orienting it by the sign of the smoothed ‘pressureSmooth’. The ‘rawFlow’ is then put through multiple layers of exponential moving average (EMA) smoothing (with ‘smoothingLength’ and derived values) to reach the final ‘mainFlow’ line. The extensive smoothing is designed to give a smooth and clear visualization of the overall market direction and magnitude.
- Dashboard Metrics Compilation: Additional metrics like flow acceleration (derivative of mainFlow), and flow continuity (correlation between close and volume) are calculated. All primary components (Flow State, Strength, Viscosity, Turbulence, Pressure, Acceleration, Continuity) are then presented in a user-configurable dashboard for ease of monitoring.
💡 Note:
The “Market Fluid Dynamics - Phen” indicator is designed to offer a unique perspective on market behavior by applying principles from fluid dynamics. It’s most effective when used to understand the underlying forces driving price rather than as a direct buy/sell signal generator in isolation. Experiment with the settings, particularly the ‘Base Lookback Period’, ‘Flow Sensitivity’, and ‘Flow Smoothing’, to find what best suits your trading style and the specific asset you are analyzing. Always combine its insights with robust risk management practices.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Smart Tools for Smarter Trades: phenlabs.com
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Smart Tools for Smarter Trades: phenlabs.com
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Join our growing community: discord.gg/phen
All content provided by PhenLabs is for informational & educational purposes only. Past performance does not guarantee future results.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.