MERV: Market Entropy & Rhythm Visualizer [BullByte]The MERV (Market Entropy & Rhythm Visualizer) indicator analyzes market conditions by measuring entropy (randomness vs. trend), tradeability (volatility/momentum), and cyclical rhythm. It provides traders with an easy-to-read dashboard and oscillator to understand when markets are structured or choppy, and when trading conditions are optimal.
Purpose of the Indicator
MERV’s goal is to help traders identify different market regimes. It quantifies how structured or random recent price action is (entropy), how strong and volatile the movement is (tradeability), and whether a repeating cycle exists. By visualizing these together, MERV highlights trending vs. choppy environments and flags when conditions are favorable for entering trades. For example, a low entropy value means prices are following a clear trend line, whereas high entropy indicates a lot of noise or sideways action. The indicator’s combination of measures is original: it fuses statistical trend-fit (entropy), volatility trends (ATR and slope), and cycle analysis to give a comprehensive view of market behavior.
Why a Trader Should Use It
Traders often need to know when a market trend is reliable vs. when it is just noise. MERV helps in several ways: it shows when the market has a strong direction (low entropy, high tradeability) and when it’s ranging (high entropy). This can prevent entering trend-following strategies during choppy periods, or help catch breakouts early. The “Optimal Regime” marker (a star) highlights moments when entropy is very low and tradeability is very high, typically the best conditions for trend trades. By using MERV, a trader gains an empirical “go/no-go” signal based on price history, rather than guessing from price alone. It’s also adaptable: you can apply it to stocks, forex, crypto, etc., on any timeframe. For example, during a bullish phase of a stock, MERV will turn green (Trending Mode) and often show a star, signaling good follow-through. If the market later grinds sideways, MERV will shift to magenta (Choppy Mode), warning you that trend-following is now risky.
Why These Components Were Chosen
Market Entropy (via R²) : This measures how well recent prices fit a straight line. We compute a linear regression on the last len_entropy bars and calculate R². Entropy = 1 - R², so entropy is low when prices follow a trend (R² near 1) and high when price action is erratic (R² near 0). This single number captures trend strength vs noise.
Tradeability (ATR + Slope) : We combine two familiar measures: the Average True Range (ATR) (normalized by price) and the absolute slope of the regression line (scaled by ATR). Together they reflect how active and directional the market is. A high ATR or strong slope means big moves, making a trend more “tradeable.” We take a simple average of the normalized ATR and slope to get tradeability_raw. Then we convert it to a percentile rank over the lookback window so it’s stable between 0 and 1.
Percentile Ranks : To make entropy and tradeability values easy to interpret, we convert each to a 0–100 rank based on the past len_entropy periods. This turns raw metrics into a consistent scale. (For example, an entropy rank of 90 means current entropy is higher than 90% of recent values.) We then divide by 100 to plot them on a 0–1 scale.
Market Mode (Regime) : Based on those ranks, MERV classifies the market:
Trending (Green) : Low entropy rank (<40%) and high tradeability rank (>60%). This means the market is structurally trending with high activity.
Choppy (Magenta) : High entropy rank (>60%) and low tradeability rank (<40%). This is a mostly random, low-momentum market.
Neutral (Cyan) : All other cases. This covers mixed regimes not strongly trending or choppy.
The mode is shown as a colored bar at the bottom: green for trending, magenta for choppy, cyan for neutral.
Optimal Regime Signal : Separately, we mark an “optimal” condition when entropy_norm < 0.3 and tradeability > 0.7 (both normalized 0–1). When this is true, a ★ star appears on the bottom line. This star is colored white when truly optimal, gold when only tradeability is high (but entropy not quite low enough), and black when neither condition holds. This gives a quick visual cue for very favorable conditions.
What Makes MERV Stand Out
Holistic View : Unlike a single-oscillator, MERV combines trend, volatility, and cycle analysis in one tool. This multi-faceted approach is unique.
Visual Dashboard : The fixed on-chart dashboard (shown at your chosen corner) summarizes all metrics in bar/gauge form. Even a non-technical user can glance at it: more “█” blocks = a higher value, colors match the plots. This is more intuitive than raw numbers.
Adaptive Thresholds : Using percentile ranks means MERV auto-adjusts to each market’s character, rather than requiring fixed thresholds.
Cycle Insight : The rhythm plot adds information rarely found in indicators – it shows if there’s a repeating cycle (and its period in bars) and how strong it is. This can hint at natural bounce or reversal intervals.
Modern Look : The neon color scheme and glow effects make the lines easy to distinguish (blue/pink for entropy, green/orange for tradeability, etc.) and the filled area between them highlights when one dominates the other.
Recommended Timeframes
MERV can be applied to any timeframe, but it will be more reliable on higher timeframes. The default len_entropy = 50 and len_rhythm = 30 mean we use 30–50 bars of history, so on a daily chart that’s ~2–3 months of data; on a 1-hour chart it’s about 2–3 days. In practice:
Swing/Position traders might prefer Daily or 4H charts, where the calculations smooth out small noise. Entropy and cycles are more meaningful on longer trends.
Day trader s could use 15m or 1H charts if they adjust the inputs (e.g. shorter windows). This provides more sensitivity to intraday cycles.
Scalpers might find MERV too “slow” unless input lengths are set very low.
In summary, the indicator works anywhere, but the defaults are tuned for capturing medium-term trends. Users can adjust len_entropy and len_rhythm to match their chart’s volatility. The dashboard position can also be moved (top-left, bottom-right, etc.) so it doesn’t cover important chart areas.
How the Scoring/Logic Works (Step-by-Step)
Compute Entropy : A linear regression line is fit to the last len_entropy closes. We compute R² (goodness of fit). Entropy = 1 – R². So a strong straight-line trend gives low entropy; a flat/noisy set of points gives high entropy.
Compute Tradeability : We get ATR over len_entropy bars, normalize it by price (so it’s a fraction of price). We also calculate the regression slope (difference between the predicted close and last close). We scale |slope| by ATR to get a dimensionless measure. We average these (ATR% and slope%) to get tradeability_raw. This represents how big and directional price moves are.
Convert to Percentiles : Each new entropy and tradeability value is inserted into a rolling array of the last 50 values. We then compute the percentile rank of the current value in that array (0–100%) using a simple loop. This tells us where the current bar stands relative to history. We then divide by 100 to plot on .
Determine Modes and Signal : Based on these normalized metrics: if entropy < 0.4 and tradeability > 0.6 (40% and 60% thresholds), we set mode = Trending (1). If entropy > 0.6 and tradeability < 0.4, mode = Choppy (-1). Otherwise mode = Neutral (0). Separately, if entropy_norm < 0.3 and tradeability > 0.7, we set an optimal flag. These conditions trigger the colored mode bars and the star line.
Rhythm Detection : Every bar, if we have enough data, we take the last len_rhythm closes and compute the mean and standard deviation. Then for lags from 5 up to len_rhythm, we calculate a normalized autocorrelation coefficient. We track the lag that gives the maximum correlation (best match). This “best lag” divided by len_rhythm is plotted (a value between 0 and 1). Its color changes with the correlation strength. We also smooth the best correlation value over 5 bars to plot as “Cycle Strength” (also 0 to 1). This shows if there is a consistent cycle length in recent price action.
Heatmap (Optional) : The background color behind the oscillator panel can change with entropy. If “Neon Rainbow” style is on, low entropy is blue and high entropy is pink (via a custom color function), otherwise a classic green-to-red gradient can be used. This visually reinforces the entropy value.
Volume Regime (Dashboard Only) : We compute vol_norm = volume / sma(volume, len_entropy). If this is above 1.5, it’s considered high volume (neon orange); below 0.7 is low (blue); otherwise normal (green). The dashboard shows this as a bar gauge and percentage. This is for context only.
Oscillator Plot – How to Read It
The main panel (oscillator) has multiple colored lines on a 0–1 vertical scale, with horizontal markers at 0.2 (Low), 0.5 (Mid), and 0.8 (High). Here’s each element:
Entropy Line (Blue→Pink) : This line (and its glow) shows normalized entropy (0 = very low, 1 = very high). It is blue/green when entropy is low (strong trend) and pink/purple when entropy is high (choppy). A value near 0.0 (below 0.2 line) indicates a very well-defined trend. A value near 1.0 (above 0.8 line) means the market is very random. Watch for it dipping near 0: that suggests a strong trend has formed.
Tradeability Line (Green→Yellow) : This represents normalized tradeability. It is colored bright green when tradeability is low, transitioning to yellow as tradeability increases. Higher values (approaching 1) mean big moves and strong slopes. Typically in a market rally or crash, this line will rise. A crossing above ~0.7 often coincides with good trend strength.
Filled Area (Orange Shade) : The orange-ish fill between the entropy and tradeability lines highlights when one dominates the other. If the area is large, the two metrics diverge; if small, they are similar. This is mostly aesthetic but can catch the eye when the lines cross over or remain close.
Rhythm (Cycle) Line : This is plotted as (best_lag / len_rhythm). It indicates the relative period of the strongest cycle. For example, a value of 0.5 means the strongest cycle was about half the window length. The line’s color (green, orange, or pink) reflects how strong that cycle is (green = strong). If no clear cycle is found, this line may be flat or near zero.
Cycle Strength Line : Plotted on the same scale, this shows the autocorrelation strength (0–1). A high value (e.g. above 0.7, shown in green) means the cycle is very pronounced. Low values (pink) mean any cycle is weak and unreliable.
Mode Bars (Bottom) : Below the main oscillator, thick colored bars appear: a green bar means Trending Mode, magenta means Choppy Mode, and cyan means Neutral. These bars all have a fixed height (–0.1) and make it very easy to see the current regime.
Optimal Regime Line (Bottom) : Just below the mode bars is a thick horizontal line at –0.18. Its color indicates regime quality: White (★) means “Optimal Regime” (very low entropy and high tradeability). Gold (★) means not quite optimal (high tradeability but entropy not low enough). Black means neither condition. This star line quickly tells you when conditions are ideal (white star) or simply good (gold star).
Horizontal Guides : The dotted lines at 0.2 (Low), 0.5 (Mid), and 0.8 (High) serve as reference lines. For example, an entropy or tradeability reading above 0.8 is “High,” and below 0.2 is “Low,” as labeled on the chart. These help you gauge values at a glance.
Dashboard (Fixed Corner Panel)
MERV also includes a compact table (dashboard) that can be positioned in any corner. It summarizes key values each bar. Here is how to read its rows:
Entropy : Shows a bar of blocks (█ and ░). More █ blocks = higher entropy. It also gives a percentage (rounded). A full bar (10 blocks) with a high % means very chaotic market. The text is colored similarly (blue-green for low, pink for high).
Rhythm : Shows the best cycle period in bars (e.g. “15 bars”). If no calculation yet, it shows “n/a.” The text color matches the rhythm line.
Cycle Strength : Gives the cycle correlation as a percentage (smoothed, as shown on chart). Higher % (green) means a strong cycle.
Tradeability : Displays a 10-block gauge for tradeability. More blocks = more tradeable market. It also shows “gauge” text colored green→yellow accordingly.
Market Mode : Simply shows “Trending”, “Choppy”, or “Neutral” (cyan text) to match the mode bar color.
Volume Regime : Similar to tradeability, shows blocks for current volume vs. average. Above-average volume gives orange blocks, below-average gives blue blocks. A % value indicates current volume relative to average. This row helps see if volume is abnormally high or low.
Optimal Status (Large Row) : In bold, either “★ Optimal Regime” (white text) if the star condition is met, “★ High Tradeability” (gold text) if tradeability alone is high, or “— Not Optimal” (gray text) otherwise. This large row catches your eye when conditions are ripe.
In short, the dashboard turns the numeric state into an easy read: filled bars, colors, and text let you see current conditions without reading the plot. For instance, five blue blocks under Entropy and “25%” tells you entropy is low (good), and a row showing “Trending” in green confirms a trend state.
Real-Life Example
Example : Consider a daily chart of a trending stock (e.g. “AAPL, 1D”). During a strong uptrend, recent prices fit a clear upward line, so Entropy would be low (blue line near bottom, perhaps below the 0.2 line). Volatility and slope are high, so Tradeability is high (green-yellow line near top). In the dashboard, Entropy might show only 1–2 blocks (e.g. 10%) and Tradeability nearly full (e.g. 90%). The Market Mode bar turns green (Trending), and you might see a white ★ on the optimal line if conditions are very good. The Volume row might light orange if volume is above average during the rally. In contrast, imagine the same stock later in a tight range: Entropy will rise (pink line up, more blocks in dashboard), Tradeability falls (fewer blocks), and the Mode bar turns magenta (Choppy). No star appears in that case.
Consolidated Use Case : Suppose on XYZ stock the dashboard reads “Entropy: █░░░░░░░░ 20%”, “Tradeability: ██████████ 80%”, Mode = Trending (green), and “★ Optimal Regime.” This tells the trader that the market is in a strong, low-noise trend, and it might be a good time to follow the trend (with appropriate risk controls). If instead it reads “Entropy: ████████░░ 80%”, “Tradeability: ███▒▒▒▒▒▒ 30%”, Mode = Choppy (magenta), the trader knows the market is random and low-momentum—likely best to sit out until conditions improve.
Example: How It Looks in Action
Screenshot 1: Trending Market with High Tradeability (SOLUSD, 30m)
What it means:
The market is in a clear, strong trend with excellent conditions for trading. Both trend-following and active strategies are favored, supported by high tradeability and strong volume.
Screenshot 2: Optimal Regime, Strong Trend (ETHUSD, 1h)
What it means:
This is an ideal environment for trend trading. The market is highly organized, tradeability is excellent, and volume supports the move. This is when the indicator signals the highest probability for success.
Screenshot 3: Choppy Market with High Volume (BTC Perpetual, 5m)
What it means:
The market is highly random and choppy, despite a surge in volume. This is a high-risk, low-reward environment, avoid trend strategies, and be cautious even with mean-reversion or scalping.
Settings and Inputs
The script is fully open-source; here are key inputs the user can adjust:
Entropy Window (len_entropy) : Number of bars used for entropy and tradeability (default 50). Larger = smoother, more lag; smaller = more sensitivity.
Rhythm Window (len_rhythm ): Bars used for cycle detection (default 30). This limits the longest cycle we detect.
Dashboard Position : Choose any corner (Top Right default) so it doesn’t cover chart action.
Show Heatmap : Toggles the entropy background coloring on/off.
Heatmap Style : “Neon Rainbow” (colorful) or “Classic” (green→red).
Show Mode Bar : Turn the bottom mode bar on/off.
Show Dashboard : Turn the fixed table panel on/off.
Each setting has a tooltip explaining its effect. In the description we will mention typical settings (e.g. default window sizes) and that the user can move the dashboard corner as desired.
Oscillator Interpretation (Recap)
Lines : Blue/Pink = Entropy (low=trend, high=chop); Green/Yellow = Tradeability (low=quiet, high=volatile).
Fill : Orange tinted area between them (for visual emphasis).
Bars : Green=Trending, Magenta=Choppy, Cyan=Neutral (at bottom).
Star Line : White star = ideal conditions, Gold = good but not ideal.
Horizontal Guides : 0.2 and 0.8 lines mark low/high thresholds for each metric.
Using the chart, a coder or trader can see exactly what each output represents and make decisions accordingly.
Disclaimer
This indicator is provided as-is for educational and analytical purposes only. It does not guarantee any particular trading outcome. Past market patterns may not repeat in the future. Users should apply their own judgment and risk management; do not rely solely on this tool for trading decisions. Remember, TradingView scripts are tools for market analysis, not personalized financial advice. We encourage users to test and combine MERV with other analysis and to trade responsibly.
-BullByte
Rhythm
Detrended Rhythm Oscillator (DRO)How to detect the current "market beat" or market cycle?
A common way to capture the current dominant cycle length is to detrend the price and look for common rhythms in the detrended series. A common approach is to use a Detrended Price Oscillator (DPO). This is done in order to identify and isolate short-term cycles.
A basic DPO description can be found here:
tradingview.sweetlogin.com
Improvements to the standard DPO
The main purpose of the standard DPO is to analyze historical data in order to observe cycle's in a market's movement. DPO can give the technical analyst a better sense of a cycle's typical high/low range as well as its duration. However, you need to manually try to "see" tops and bottoms on the detrended price and measure manually the distance from low-low or high-high in order to derive a possible cycle length.
Therefore, I added the following improvements:
1) Using a DPO to detrend the price
2) Indicate the turns of the detrended price with a ZigZag lines to better see the tops/bottoms
3) Detrend the ZigZag to remove price amplitude between turns to even better see the cyclic turns ("rhythm")
4) Measure the distance from last detrended zigzag pivot (high-high / low-low) and plot the distance in bars above/below the turn
Now, you can clearly see the rhythm of the dataset indicated by the Detrended Rhythm Oscillator including the exact length between the turns. This makes the procedure to "spot" turns and "measure" distance more simple for the trader.
How to use this information
The purpose is to check if there is a common rhythm or beat in the underlying dataset. To check that, look for recurring pattern in the numbers. E.g. if you often see the same measured distance, you can conclude that there is a major dominant cycle in this market. Also watch for harmonic relations between the numbers. So in the example above you see the highlighted cluster of detected length of around 40,80 and 120. There three numbers all have a harmonic relation to 40.
Once you have this cyclic information, you can use this number to optimize or tune technical indicators based on the current dominant cycle length. E.g. set the length parameter of a technical indicator to the detected harmonic length with the DRO indicator.
Example Use-Case
You can use this information to set the input for the following free public open-source script:
Disclaimer
This is not meant to be a technical indicator on its own and the derived cyclic length should not be used to forecast the next turn per se. The indicator should give you an indication of the current market beat or dominant beats which can be use to further optimize other oscillator or trading related settings.
Options & settings
The indicator allows to plot different versions. It allows to plot the original DPO, the DRO with ZigZag lines, the DRO with detrended ZigZag lines and length labels on/off. You can turn on or off these version in the indicator settings. So you can tweak it visually to your own needs.