Relative Volatility Mass [SciQua]The ⚖️  Relative Volatility Mass (RVM)  is a volatility-based tool inspired by the  Relative Volatility Index (RVI) .  
While the RVI measures the  ratio  of upward to downward volatility over a period, RVM takes a different approach:  
 
 It  sums  the standard deviation of price changes over a rolling window, separating  upward volatility  from  downward volatility .  
 The result is a measure of the  total “volatility mass”  over a user-defined period, rather than an average or normalized ratio.  
 
This makes RVM particularly useful for identifying sustained high-volatility conditions without being diluted by averaging.  
────────────────────────────────────────────────────────────
╭────────────╮
       How It Works 
╰────────────╯
1.  Standard Deviation Calculation   
     • Computes the standard deviation of the chosen `Source` over a `Standard Deviation Length` (`stdDevLen`).
2.  Directional Separation   
     • Volatility on up bars (`chg > 0`) is treated as  upward volatility .  
     • Volatility on down bars (`chg < 0`) is treated as  downward volatility .
3.  Rolling Sum   
     • Over a `Sum Length` (`sumLen`), the upward and downward volatilities are summed separately using `math.sum()`.
4.  Relative Volatility Mass   
     • The two sums are added together to get the  total volatility mass  for the rolling window.
Formula:  
RVM = Σ(σ up) + Σ(σ down)  
where σ is the standard deviation over `stdDevLen`.
╭────────────╮
          Key Features 
╰────────────╯
 
 Directional Volatility Tracking  – Differentiates between volatility during price advances vs. declines.  
 Rolling Volatility Mass  – Shows the total standard deviation accumulation over a given period.  
 Optional Smoothing  – Multiple MA types, including SMA, EMA, SMMA (RMA), WMA, VWMA.  
 Bollinger Band Overlay  – Available when SMA is selected, with adjustable standard deviation multiplier.  
 Configurable Source  – Apply RVM to `close`, `open`, `hl2`, or any custom source.  
 
╭─────╮
       Usage 
╰─────╯
 
 Trend Confirmation:  High RVM values can confirm strong trending conditions.  
 Breakout Detection:  Spikes in RVM often precede or accompany price breakouts.  
 Volatility Cycle Analysis:  Compare periods of contraction and expansion.  
 
RVM is not bounded like the RVI, so absolute values depend on market volatility and chosen parameters.  
Consider normalizing or using smoothing for easier visual comparison.  
╭────────────────╮
             Example Settings 
╰────────────────╯
 
 Short-term volatility detection:  `stdDevLen = 5`, `sumLen = 10`  
 Medium-term trend volatility:  `stdDevLen = 14`, `sumLen = 20`  
 Enable `SMA + Bollinger Bands` to visualize when volatility is unusually high or low relative to recent history.  
 
╭───────────────────╮
                Notes & Limitations 
╰───────────────────╯
 
 Not a directional signal by itself — use alongside price structure, volume, or other indicators.  
 Higher `sumLen` will smooth short-term fluctuations but reduce responsiveness.  
 Because it sums, not averages, values will scale with both volatility and chosen window size.  
 
╭───────╮
       Credits 
╰───────╯
 
 Based on the  Relative Volatility Index  concept by Donald Dorsey (1993).  
 TradingView
 SciQua - Joshua Danford
Sciqua
Squeeze Momentum Regression Clouds [SciQua]╭──────────────────────────────────────────────╮
                ☁️ Squeeze Momentum Regression Clouds  
╰──────────────────────────────────────────────╯
 🔍 Overview 
The  Squeeze Momentum Regression Clouds  (SMRC) indicator is a powerful visual tool for identifying  price compression ,  trend strength , and  slope momentum  using multiple layers of linear regression Clouds. Designed to extend the classic squeeze framework, this indicator captures the behavior of price through dynamic slope detection, percentile-based spread analytics, and an optional UI for trend inspection — across up to  four customizable regression Clouds .
────────────────────────────────────────────────────────────
╭────────────────╮
        ⚙️ Core Features 
╰────────────────╯
 
 Up to 4 Regression Clouds  – Each Cloud is created from a top and bottom linear regression line over a configurable lookback window.
 Slope Detection Engine  – Identifies whether each band is rising, falling, or flat based on slope-to-ATR thresholds.
 Spread Compression Heatmap  – Highlights compressed zones using yellow intensity, derived from historical spread analysis.
 Composite Trend Scoring  – Aggregates directional signals from each Cloud using your chosen weighting model.
 Color-Coded Candles  – Optional candle coloring reflects the real-time composite score.
 UI Table  – A toggleable info table shows slopes, compression levels, percentile ranks, and direction scores for each Cloud.
 Gradient Cloud Styling  – Apply gradient coloring from Cloud 1 to Cloud 4 for visual slope intensity.
 Weight Aggregation Options  – Use equal weighting, inverse-length weighting, or max pooling across Clouds to determine composite trend strength.
 
────────────────────────────────────────────────────────────
╭──────────────────────────────────────────╮
                             🧪 How to Use the Indicator 
                  1. Understand Trend Bias with Cloud Colors 
╰──────────────────────────────────────────╯
Each Cloud changes color based on its current slope:
 
 Green  indicates a rising trend.
 Red  indicates a falling trend.
 Gray  indicates a flat slope — often seen during chop or transitions.
 
Cloud 1 typically reflects short-term structure, while Cloud 4 represents long-term directional bias. Watch for multi-Cloud alignment — when all Clouds are green or red, the trend is strong. Divergence among Clouds often signals a potential shift.
────────────────────────────────────────────────────────────
╭───────────────────────────────────────────────╮
                    2. Use Compression Heat to Anticipate Breakouts 
╰───────────────────────────────────────────────╯
The space between each Cloud’s top and bottom regression lines is measured, normalized, and analyzed over time. When this spread tightens relative to its history, the script highlights the band with a  yellow compression glow .
This visual cue helps identify  squeeze zones  before volatility expands. If you see compression paired with a changing slope color (e.g., gray to green), this may indicate an impending breakout.
────────────────────────────────────────────────────────────
╭─────────────────────────────────╮
                3. Leverage the Optional Table UI 
╰─────────────────────────────────╯
The indicator includes a dynamic, floating table that displays real-time metrics per Cloud. These include:
 
 Slope direction and value , with historical Min/Max reference.
 Top and Bottom percentile ranks , showing how price sits within the Cloud range.
 Current spread width , compared to its historical norms.
 Composite score , which blends trend, slope, and compression for that Cloud.
 
You can customize the table’s position, theme, transparency, and whether to show a combined summary score in the header.
────────────────────────────────────────────────────────────
╭─────────────────────────────────────────────╮
                   4. Analyze Candle Color for Composite Signals 
╰─────────────────────────────────────────────╯
When enabled, the indicator colors candles based on a weighted composite score. This score factors in:
 
 The signed slope of each Cloud (up, down, or flat)
 The percentile pressure from the top and bottom bands
 The degree of spread compression
 
Expect  green candles  in bullish trend phases,  red candles  during bearish regimes, and  gray candles  in mixed or low-conviction zones.
Candle coloring provides a  visual shorthand for market conditions , useful for intraday scanning or historical backtesting.
────────────────────────────────────────────────────────────
╭────────────────────────╮
          🧰 Configuration Guidance 
╰────────────────────────╯
To tailor the indicator to your strategy:
 
 Use  Cloud lengths  like 21, 34, 55, and 89 for a balanced multi-timeframe view.
 Adjust the  slope threshold  (default 0.05) to control how sensitive the trend coloring is.
 Set the  spread floor  (e.g., 0.15) to tune when compression is detected and visualized.
 Choose your  weighting style : Inverse Length (favor faster bands), Equal, or Max Pooling (most aggressive).
 Set  composite weights  to emphasize trend slope, percentile bias, or compression—depending on your market edge.
 
────────────────────────────────────────────────────────────
╭────────────────╮
         ✅ Best Practices 
╰────────────────╯
 
 Use aligned Cloud colors across all bands to confirm trend conviction.
 Combine slope direction with compression glow for early breakout entry setups.
 In choppy markets, watch for  Clouds 1 and 2  turning flat while  Clouds 3 and 4  remain directional — a sign of potential trend exhaustion or consolidation.
 Keep the table enabled during backtesting to manually evaluate how each Cloud behaved during price turns and consolidations.
 
────────────────────────────────────────────────────────────
╭───────────────────────╮
          📌 License & Usage Terms 
╰───────────────────────╯
This script is provided under the  Creative Commons Attribution-NonCommercial 4.0 International License .
✅ You are  allowed  to:
 
 Use this script for personal or educational purposes
 Study, learn, and adapt it for your own non-commercial strategies
 
❌ You are  not allowed  to:
 
 Resell or redistribute the script without permission
 Use it inside any paid product or service
 Republish without giving clear attribution to the original author
 
For  commercial licensing , private customization, or collaborations, please contact Joshua Danford directly.
Auto Channel [SciQua]Auto Channel  
 Purpose 
Auto Channel   finds the single best parallel price channel from recent price action and keeps it updated in real time. It uses ZigZag pivots to build candidate channels, scores each candidate for quality, then plots the winner. When price closes outside the channel, the script flags a breakout and can fire alerts.
 How it works 
1.  ZigZag pivots 
     The script uses TradingView’s TradingView/ZigZag/7 library to generate a stream of swing highs and lows based on a percentage reversal threshold and a leg depth. These pivots are the only points the channel logic evaluates, which keeps the search fast and focused on structure rather than noise.
2.  Channel candidates 
 From the most recent pivots, the script forms all combinations of two swing highs and two swing lows.
 It computes a slope for the high line and a slope for the low line and requires that they be nearly parallel within a user-defined tolerance.
 
3.  Quality scoring and selection 
     For every valid candidate, the script checks the recent pivot segments against the trial channel and computes:
 
 Inside ratio: fraction of tested pivots that sit fully inside the channel after applying the tolerance buffer.
 Violation sum: total magnitude of the breaches for any pivots outside the channel.
 Current width: distance between upper and lower lines at the current bar.
 
The “best” channel is chosen by:
1. highest inside ratio
2. then widest current width
3. then smallest violation sum
4.  Plot and projection 
     The upper and lower lines are anchored to the chosen pivot pairs and extend to the left. The script also projects each line to the current bar to compute the live upper and lower channel prices. Those levels drive the breakout checks and alerts.
5.  Breakouts and alerts 
     A breakout is detected when the bar closes above the projected upper line or closes below the projected lower line, after applying the tolerance buffer. Triangle markers highlight fresh breakouts, and you can enable alert conditions to automate notification or strategy handoff.
Inputs:
 ZigZag 
 
 Price deviation for reversals (%)
Default 0.2. Larger values produce fewer, larger swings. Smaller values produce more, smaller swings.
 Pivot legs
Default 2. Controls the lookback depth ZigZag uses to confirm pivots.
 ZigZag Color
Visual only.
 
 Tip: If you are not seeing a stable channel, increase the ZigZag percentage to reduce minor swings. 
 Channel search 
 
 Number of recent pivots to consider
Default 12. Higher values search more history and try more channel combinations. Lower values make the search faster and more reactive.
 Max slope difference for parallel
Default 0.0005. Maximum allowed difference between the upper and lower line slopes. Smaller values enforce stricter parallelism.
 Max price tolerance outside channel
Default 0.0. A buffer added to the channel boundaries during validation and breakout checks. Use this to ignore tiny wicks that poke the lines.
 Minimum inside to outside pivots ratio for valid channel (0.00–1.00)
Default 1.00. Require that at least this fraction of checked pivots lie inside the channel. For a more permissive fit, try 0.60 to 0.85.
 
 Styling 
 
 Upper Line Color
 Lower Line Color
 Breakout Above Color
 Breakout Below Color
 
 Plots and visuals 
 
 Upper channel line
 Lower channel line
 Triangle markers on the bar that first confirms a close outside the channel, above or below. 
Lines extend left from their pivot anchors. Projection to the current bar is used internally to test for breakouts and to set alerts.
 Alerts 
 
 The script defines two alert conditions:
Close Above Channel
 Triggers when the bar closes above the projected upper line plus tolerance.
Close Below Channel
 Triggers when the bar closes below the projected lower line minus tolerance.
 
 Practical usage 
 
 Trend channels 
In a steady trend, a high inside ratio with a moderate width often highlights the dominant channel. Consider trend entries near the lower line in an uptrend or near the upper line in a downtrend, with exits or stops beyond the opposite boundary.
 Breakout trades 
Combine the channel breakout alert with volume or a separate momentum filter. The tolerance input helps avoid false triggers from small wicks.
 Tuning for timeframe and symbol 
• Faster markets or lower timeframes usually benefit from a larger ZigZag percentage and a smaller pivot count.
• Slower markets or higher timeframes can use more pivots and a tighter slope difference to enforce cleaner geometry.
 
 Notes and limitations 
 
 Channels are derived from ZigZag pivots. If your ZigZag settings change, the detected channel will also change.
 The script plots only the single best channel at any time to keep the chart clean.
 Breakout markers appear on confirmed bars. For historical bars, markers appear only where a breakout would have been confirmed at that time.
 Lines extend left from their anchors. The script projects the lines internally to the current bar for checks and alerts.
 
 License and attribution 
 License 
Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).
Open source for educational and personal use only. Commercial use requires written permission.
 Attribution 
© 2025 SciQua — Joshua Danford
 Libraries 
Uses TradingView/ZigZag/7.
 Changelog 
 
 v1.0
Initial release. Automatic parallel channel detection from ZigZag pivots, quality scoring, live plotting, and close-based breakout alerts.
 
 FAQ 
 
 Why do I not see any channel sometimes?
There may not be a valid pair of highs and lows that pass the slope, inside ratio, and tolerance checks. Loosen the constraints by increasing Max slope difference, lowering Minimum inside ratio, or increasing the ZigZag percentage.
 The channel looks too narrow or too wide?
Adjust Number of recent pivots and Minimum inside ratio. A higher inside ratio tends to favor cleaner, sometimes wider channels. A lower ratio may admit narrower, more reactive channels.
 How can I reduce false breakout alerts?
Increase Max price tolerance outside channel to ignore small wicks. Add a volume or momentum confirmation in your personal alert workflow.
 
 Thank you for using Auto Channel  . Feedback and improvements are welcome.


