OPEN-SOURCE SCRIPT
已更新 Boshmann's Regime Counters

Summary of Boshmann's Regime Counters
At its core, this indicator is designed to remove human subjectivity from chart reading by translating market behavior into purely objective, mathematically defined states. Rather than relying on discretionary trendlines or "gut feelings" about market speed, it uses robust statistical baselines to continuously classify the market into discrete Trend and Volatility regimes.
For TradingView users, this provides an immediate, systematic context of the market environment, which is crucial because trading strategies (like mean-reversion vs. trend-following) only perform well when aligned with the correct market state.
1. Trend Regime Classification (Directional Bias)
The indicator evaluates moving average alignments to determine the structural trend. It requires both price position and momentum to agree before declaring a strong trend:
Bull: The closing price is strictly above a long-term baseline (200 SMA) AND short-term momentum (20 SMA) is leading the medium-term momentum (100 SMA).
Bear: The closing price is below the 200 SMA AND the 20 SMA has crossed below the 100 SMA.
Sideways: Any state where the price and moving averages are in conflict or tangled.
Visuals: The chart bars are painted dynamically (Green for Bull, Red for Bear, Golden for Sideways) so the current regime is instantly visible.
2. Volatility Regime Classification (Market Speed)
Instead of using fixed point values to measure volatility (which break down across different timeframes and assets), the indicator uses an Adaptive Z-Score of the Average True Range (ATR). By looking back over a large sample size (250 periods), it calculates a rolling mean and standard deviation of the ATR. This normalizes volatility into a universal metric:
Quiet (Z-Score < -0.5): The market is contracting and experiencing significantly below-average movement.
Normal (Z-Score -0.5 to 0.5): The market is operating within its standard, expected historical variance.
Volatile (Z-Score > 0.5): The market is expanding, experiencing statistically significant, out-sized movement.
3. The Statistics Dashboard
The script anchors a real-time statistical dashboard to the chart. It tallies the exact number of bars—and calculates the overall historical percentage—spent in each specific trend and volatility regime.
What this does for TradingView users:
Strategy Alignment: By quantifying exactly how much time an asset spends trending versus chopping sideways, traders can objectively decide whether to deploy a trend-following system or a range-bound strategy on that specific asset.
Contextual Awareness: The adaptive Z-score prevents users from being caught off guard by volatility expansion, giving them a mathematical warning when the market shifts from "Quiet" accumulation into "Volatile" distribution.
Backtesting Validation: The on-chart percentages give quantitative traders immediate insight into the asset's structural personality over the loaded history (e.g., realizing an asset is only in a "Strong Bull" state 25% of the time helps set realistic win-rate expectations).
At its core, this indicator is designed to remove human subjectivity from chart reading by translating market behavior into purely objective, mathematically defined states. Rather than relying on discretionary trendlines or "gut feelings" about market speed, it uses robust statistical baselines to continuously classify the market into discrete Trend and Volatility regimes.
For TradingView users, this provides an immediate, systematic context of the market environment, which is crucial because trading strategies (like mean-reversion vs. trend-following) only perform well when aligned with the correct market state.
1. Trend Regime Classification (Directional Bias)
The indicator evaluates moving average alignments to determine the structural trend. It requires both price position and momentum to agree before declaring a strong trend:
Bull: The closing price is strictly above a long-term baseline (200 SMA) AND short-term momentum (20 SMA) is leading the medium-term momentum (100 SMA).
Bear: The closing price is below the 200 SMA AND the 20 SMA has crossed below the 100 SMA.
Sideways: Any state where the price and moving averages are in conflict or tangled.
Visuals: The chart bars are painted dynamically (Green for Bull, Red for Bear, Golden for Sideways) so the current regime is instantly visible.
2. Volatility Regime Classification (Market Speed)
Instead of using fixed point values to measure volatility (which break down across different timeframes and assets), the indicator uses an Adaptive Z-Score of the Average True Range (ATR). By looking back over a large sample size (250 periods), it calculates a rolling mean and standard deviation of the ATR. This normalizes volatility into a universal metric:
Quiet (Z-Score < -0.5): The market is contracting and experiencing significantly below-average movement.
Normal (Z-Score -0.5 to 0.5): The market is operating within its standard, expected historical variance.
Volatile (Z-Score > 0.5): The market is expanding, experiencing statistically significant, out-sized movement.
3. The Statistics Dashboard
The script anchors a real-time statistical dashboard to the chart. It tallies the exact number of bars—and calculates the overall historical percentage—spent in each specific trend and volatility regime.
What this does for TradingView users:
Strategy Alignment: By quantifying exactly how much time an asset spends trending versus chopping sideways, traders can objectively decide whether to deploy a trend-following system or a range-bound strategy on that specific asset.
Contextual Awareness: The adaptive Z-score prevents users from being caught off guard by volatility expansion, giving them a mathematical warning when the market shifts from "Quiet" accumulation into "Volatile" distribution.
Backtesting Validation: The on-chart percentages give quantitative traders immediate insight into the asset's structural personality over the loaded history (e.g., realizing an asset is only in a "Strong Bull" state 25% of the time helps set realistic win-rate expectations).
發行說明
prevent override of candle colours for bull and bear.發行說明
number of bars in table is calculated dynamically according to what is displayed on screen now發行說明
Boshmann's Regime CountersNot all markets are the same, some trend smoothly, while others are volatile and choppy. A trading strategy that prints money in a quiet bull market will often loose money in a sideways volatile market. This indicator automatically classifies the current "market weather" so you know exactly when your strategy has an edge and when you should stay out.
How to Use It: This tool calculates the percentage of time an asset spends in different trend directions (Bull, Bear, Sideways) and volatility states (Quiet, Normal, Volatile). It also tracks the average price swing ("Avg Pts") for each state, giving you hard data to widen or tighten your stop-losses based on current market conditions.
Note: For the complete market analysis framework, this counter should be used in conjunction with the Boshmann's Market Regime Histogram and Boshmann's Volatility Histogram indicators to visually spot live regime shifts on your chart.
(Side Note on the Chart Image: The screenshot provided includes a 150 SMA on the chart. This is for pure visual illustration to help anchor the eye to the general baseline trend. The indicator does its own internal math and does not require you to plot any specific moving averages on your actual chart!)
Recent updates:
- We added a new dynamic calculation that tracks the True Range of every single bar and divides it by the asset's minimum tick size to give you an accurate Average Points metric for each regime, no matter what asset you are trading.
It answers the question: How much distance can I expect this asset to swing on a typical day in this specific market condition?"
Example:
trading the S&P 500 E-mini futures (ES).
Quiet Regime: Avg Pts = 100
Volatile Regime: Avg Pts = 400
This tells you: "When the market is Quiet, a normal daily candle swings about 100 ticks top-to-bottom. If I'm placing a trade today, I should keep my stop-loss tight and my profit target realistic. But when the market flips to Volatile, the daily swings violently quadruple to 400 ticks. If I try to use my tight 'Quiet' stop-loss today, I will get chopped out immediately. I need to size down my position and place my stops 4 times wider to survive the chop!"
it give you a number to help you adjust your stop-losses and profit targets depending on the "weather" of the market. - We made the statistics table significantly more compact and we cleaned up the data by using rounded, right-aligned numbers without decimals, easy to compare values at a single glance.
發行說明
you can change the box size to small if need be 開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。