OPEN-SOURCE SCRIPT

Squeeze Weekday Frequency [CHE]

54
Squeeze Weekday Frequency [CHE] — Tracks historical frequency of low-volatility squeezes by weekday to inform timing of low-risk setups.

Summary
This indicator monitors periods of unusually low volatility, defined as when the average true range falls below a percentile threshold, and tallies their occurrences across each weekday. By aggregating these counts over the chart's history, it reveals patterns in squeeze frequency, helping traders avoid or target specific days for reduced noise. The approach uses persistent counters to ensure accurate daily tallies without duplicates, providing a robust view of weekday biases in volatility regimes.

Motivation: Why this design?
Traders often face inconsistent signal quality due to varying volatility patterns tied to the trading calendar, such as quieter mid-week sessions or busier Mondays. This indicator addresses that by binning low-volatility events into weekday buckets, allowing users to spot recurring low-activity days where trends may develop with less whipsaw. It focuses on historical aggregation rather than real-time alerts, emphasizing pattern recognition over prediction.

What’s different vs. standard approaches?
- Reference baseline: Traditional volatility trackers like simple moving averages of range or standalone Bollinger Band squeezes, which ignore temporal distribution.
- Architecture differences:
- Employs array-based persistent counters for each weekday to accumulate events without recounting.
- Includes duplicate prevention via day-key tracking to handle sparse data.
- Features on-demand sorting and conditional display modes for focused insights.
- Practical effect: Charts show a persistent table of ranked weekdays instead of transient plots, making it easier to glance at biases like higher squeezes on Fridays, which reduces the need for manual logging and highlights calendar-driven edges.

How it works (technical)
The indicator first computes the average true range over a specified lookback period to gauge recent volatility. It then ranks this value against its own history within a sliding window to identify squeezes when the rank drops below the threshold. Each bar's timestamp is resolved to a weekday using the selected timezone, and a unique day identifier is generated from the date components.

On detecting a squeeze and valid price data, it checks against a stored last-marked day for that weekday to avoid multiple counts per day. If it's a new occurrence, the corresponding weekday counter in an array increments. Total days and data-valid days are tracked separately for context.

At the chart's last bar, it sums all counters to compute shares, sorts weekdays by their squeeze proportions, and populates a table with the selected subset. The table alternates row colors and highlights the peak weekday. An info label above the final bar summarizes totals and the top day. Background shading applies a faint red to squeeze bars for visual confirmation. State persists via variable arrays initialized once, ensuring counts build incrementally without resets.

Parameter Guide
ATR Length — Sets the lookback for measuring average true range, influencing squeeze sensitivity to short-term swings. Default: 14. Trade-offs/Tips: Shorter values increase responsiveness but raise false positives in chop; longer smooths for stability, potentially missing early squeezes.

Percentile Window (bars) — Defines the history length for ranking the current ATR, balancing recent relevance with sample size. Default: 252. Trade-offs/Tips: Narrower windows adapt faster to regime shifts but amplify noise; wider ones stabilize ranks yet lag in fast markets—aim for 100-500 bars on daily charts.

Squeeze threshold (PR < x) — Determines the cutoff for low-volatility classification; lower values flag rarer, tighter squeezes. Default: 10.0. Trade-offs/Tips: Tighter thresholds (under 5) yield fewer but higher-quality signals, reducing clutter; looser (over 20) captures more events at the cost of relevance.

Timezone — Selects the reference for weekday assignment; exchange default aligns with asset's session. Default: Exchange. Trade-offs/Tips: Use custom for cross-market analysis, but verify alignment to avoid offset errors in global pairs.

Show — Toggles the results table visibility for quick on/off of the display. Default: true. Trade-offs/Tips: Disable in multi-indicator setups to save screen space; re-enable for periodic reviews.

Pos — Positions the table on the chart pane for optimal viewing. Default: Top Right. Trade-offs/Tips: Bottom options suit long-term charts; test placements to avoid overlapping price action.

Font — Adjusts text size in the table for readability at different zooms. Default: normal. Trade-offs/Tips: Smaller fonts fit more data but strain eyes on small screens; larger for presentations.

Dark — Applies a dark color scheme to the table for contrast against chart backgrounds. Default: true. Trade-offs/Tips: Toggle false for light themes; ensures legibility without manual recoloring.

Display — Filters table rows to show all, top three, or bottom three weekdays by squeeze share. Default: All. Trade-offs/Tips: Use "Top 3" for focus on high-frequency days in active trading; "All" for full audits.

Reading & Interpretation
Red-tinted backgrounds mark individual squeeze bars, indicating current low-volatility conditions. The table's summary row shows the highest squeeze count, its percentage of total events, and the associated weekday in teal. Detail rows list selected weekdays with their absolute counts, proportional shares, and a left arrow for the peak day—higher percentages signal days where squeezes cluster, suggesting potential for calmer trend development. The info label reports overall days observed, valid data days, and reiterates the top weekday with its count. Drifting counts toward zero on a weekday imply rarity, while elevated ones point to habitual low-activity sessions.

Practical Workflows & Combinations
- Trend following: Scan for squeezes on high-frequency weekdays as entry filters, confirming with higher highs or lower lows in the structure; pair with momentum oscillators to time breaks.
- Exits/Stops: On low-squeeze days, widen stops for breathing room, tightening them during peak squeeze periods to guard against false breaks—use the table's percentages as a regime proxy.
- Multi-asset/Multi-TF: Defaults work across forex and indices on hourly or daily frames; for stocks, adjust percentile window to 100 for shorter histories. Scale thresholds up by 5-10 points for high-vol assets like crypto to maintain signal sparsity.

Behavior, Constraints & Performance
- Repaint/confirmation: Counts update only on confirmed bars via day-key changes, with no future references—live bars may shade red tentatively but tallies finalize at session close.
- security()/HTF: Not used, so no higher-timeframe repaint risks; all computations stay in the chart's resolution.
- Resources: Relies on a fixed-size array of seven elements and small loops for sorting and table fills, capped at 5000 bars back—efficient for most charts but may slow on very long intraday histories.
- Known limits: Ignores weekends and holidays implicitly via data presence; early chart bars lack full percentile context, leading to initial undercounting; assumes continuous sessions, so gaps in data (e.g., news halts) skew totals.

Sensible Defaults & Quick Tuning
Start with the built-in values for broad-market daily charts: ATR at 14, window at 252, threshold at 10. For noisier environments, lower the threshold to 5 and shorten the window to 100 to prioritize rare squeezes. If too few events appear, raise the threshold to 15 and extend ATR to 20 for broader capture. To combat overcounting in sparse data, widen the window to 500 while keeping others stock—monitor the info label's data-days count before trusting patterns.

What this indicator is—and isn’t
This serves as a statistical overlay for spotting calendar-based volatility biases, aiding in session selection and filter design. It is not a standalone signal generator, predictive model, or risk manager—integrate it with price action, volume, and broader strategy rules for decisions.

Disclaimer

The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.

Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.

By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.

Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.

Best regards and happy trading

Chervolino

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.