OPEN-SOURCE SCRIPT
업데이트됨

TrendMatrix Auto-Period Trend Screener

2 481
TrendMatrix Auto-Period Trend Screener - Trend Smart.

Most traditional screeners force you to view the market through a rigid, fixed lens—asking questions like, "What are the best performers over the last 90 days?" The problem is that stocks do not all move on the same 90-day cycle. Forcing a fixed lookback period onto every ticker guarantees you will miss the true underlying trend for many of them.

The "TrendMatrix Auto-Period Trend Screener" solves this by dynamically adapting to the unique rhythm of every single stock. Instead of you telling the indicator what timeframe to look at, the indicator tells you which timeframe mathematically fits the stock best.

1. Per-Ticker Auto-Period Selection

You no longer have to guess the correct lookback window. For every ticker in your custom universe, the engine runs a regression analysis across multiple candidate periods (ranging from 1 month to 4 years). It calculates the Pearson R correlation of the log(close) against time.

The engine automatically locks onto the period with the strongest log-linear trend. This means the screener might evaluate Nvidia based on a 189-day cycle, while simultaneously measuring a gold miner on a 63-day cycle—because those are the windows where their respective trends are mathematically the cleanest.

2. TAR & Sharpe: The Ultimate Filtering Pair

Once the engine finds a stock's optimal trend period, it computes two vital metrics to help you rank them:

TAR (Trend Annualised Return): This is the Compound Annual Growth Rate (CAGR) computed strictly over the stock's auto-selected best window. It standardizes growth rates so you can directly compare a stock on a 3-month cycle against one on a 1-year cycle.

The Sharpe Ratio: Growth means nothing if the path to get there is violently volatile. The Sharpe ratio measures risk-adjusted return over that same best-fit period. By default, the screener ranks your list by Sharpe, surfacing the best combination of trend strength and trend quality (smoothness) directly to the top.

3. The Dual Stop System

Managing risk requires context. This screener replaces arbitrary stop-losses with a dynamic, dual-column system directly in your dashboard:

Stop (Trend) — Peak-Anchored: This stop adapts to each name's actual cycle. It anchors to the highest close within the stock's unique best-fit window. Short, aggressive cycles get tight stops; long, established cycles get deeper stops.

Stop (Event) — Entry-Anchored: This answers the question: "If I had entered this stock at the start of my recent target window, where would my stop be now?" It is anchored purely to the price at the start of your defined post-event window.

By tracking both, you always know exactly how much structural buffer remains in the macro trend, and how much risk remains on a recent tactical entry.

---

Additional Core Features

Four Thematic Universe Slots: The screener allows you to actively switch between 4 different ticker lists (e.g., AI Infrastructure, Gold Miners, Bioscience, Energy). You can use the curated defaults, build your own custom lists, or merge both together. Because custom tickers are stored in your script settings, updating the indicator never wipes your hard work.

Adaptive Regression Channel: The chart overlay features a regression channel that defaults to a long-term view, but automatically snaps to a short-term view if the price structurally breaks below the long-term lower bound.

Contextual Zig-Zag: A built-in, percentage-based zig-zag helps you instantly gauge the normal "swing scale" of a stock, ensuring you don't get shaken out by a routine 10% pullback on a highly volatile ticker.

Actionable Alerts: Built-in alerts fire immediately when any ticker breaches—or recovers—either its Trend Stop or its Event Stop.

How to Use It

1. Select your Universe: Choose one of the 4 slots and define your tickers.
2. Calibrate your Filters: Set your minimum R values to remove choppy, trendless noise.
3. Read the Dashboard: Look for names at the top with a high Sharpe ratio (smooth trend), a strong TAR (high growth), and a green Action column (price is safely above its adaptive stop).
릴리즈 노트
I added a Secondary Intraday Zig Zag Engine.
릴리즈 노트
TrendMatrix V2: Auto-Period Screener + Institutional Regime Engine.

Welcome to the major evolution of the TrendMatrix ecosystem. While the original version excelled at identifying the cleanest macro trends across custom universes, this major upgrade bridges the gap between macro scanning and tactical execution.

I have introduced a comprehensive Regime Overlay Engine and a real-time Symbol X-Ray HUD to give you institutional-grade momentum and volatility reads right on your chart.

What's New in This Upgrade?
• Institutional Regime Bands: The chart overlay now features adaptive volatility bands built on statistical Z-scores. These bands dynamically compress and expand to identify macro liquidity pools and structural price ranges.
• Modular Execution Logic: Tailor your trade triggers to your specific execution philosophy. You can choose between 'Conservative' (waits for trend slope confirmation), 'Fast Centerline Break' (reacts instantly to momentum shifts), or 'Band Reversal' for anticipatory mean-reversion at mathematical extremes.
• Symbol X-Ray HUD: A dedicated, real-time dashboard providing a deep-dive into the active symbol's vitals. The HUD surfaces crucial metrics:
◦ Signal Confidence: A blended percentage score derived from Z-score extensions, trend slopes, and relative volume.
◦ Risk to Invalidation: Measures the percentage distance to structural invalidation (the opposite volatility band) to keep your risk/reward in check.
◦ Relative Volume (RVOL): An instant read on current volume versus its 50-period average.
◦ Volatility Regime: Multi-timeframe volatility percentiles showing whether the macro regime is currently 'Expanding' (favoring momentum) or 'Compressed' (favoring mean reversion).
• Auto-Fibonacci Engine: Automatically plots significant structural Fibonacci retracement levels based on your selected lookback horizon (ranging from fast scalping micro-pivots to macro market cycles).
Core Capabilities
• TAR Screener Engine: Scans 4 thematic or custom slots (up to 39 tickers each) to find the cleanest compounding trends. The engine auto-selects the statistically best-fit lookback window and computes the Trend Annualised Return (TAR) and Sharpe ratio.
• Auto-Period Regression Channels: Automatically plots the best Pearson's R log-linear regression channel out of 19 potential candidates. The channel features an adaptive mode that seamlessly drops from Long-Term to Short-Term tracking when a structural breakdown occurs.
• Dynamic Stop-Loss Architecture: Track Peak-anchored Trend Stops and Entry-anchored Event Stops directly on the chart and within the screener to manage active positions adaptively.
• Actionable Alerts: Set built-in alerts for Trend Breaches/Recoveries and Event Breaches/Recoveries to notify you when prices cross critical stop thresholds.
How to Use the Complete System: Use the screener table to scan your custom watchlists for the highest-Sharpe, cleanest trending assets. Once an asset catches your eye, switch your focus to the new Regime Bands and X-Ray HUD. The HUD will validate your execution timing, telling you instantly if the trade has the institutional momentum, favorable volatility state, and volume required to follow through.
릴리즈 노트
Update — localization, intraday stability, unified HUD
• Timezone options expanded for the screener header: IST, TRT (Istanbul), Gulf, PKT, Dhaka, and Tashkent now sit alongside New York / London / Tokyo / UTC.
• Fixed a crash when switching to intraday timeframes. Screener metrics are computed on daily data by design; on intraday the table now shows a short notice and the regression channel, regime overlay, and HUD stay active.
• Hardened the universe loops against empty ticker lists, so a slot left blank no longer errors.
• Combined the chart trend read and the regime read into a single HUD with section headers, a configurable title, per-cell tooltips, and a top-gap control to clear the chart legend.
• Added open-source attribution for the auto-period Pearson's R method (see source header).
릴리즈 노트
Screenshot update
릴리즈 노트
New Screener Column: Trend Persistence (Held% · n)

I have replaced the TAR column with a new column called Persistence (Held% · n).

The old TAR column only showed how fast a trend moved up. The new Persistence column shows if the trend is strong enough to last a long time.

How It Works
• The Math: The script looks at the history of the asset. It finds every time there was a "strong-trend state" in the past. Then, it counts forward 21 bars. Finally, it checks: Did the price stay safely above the trend stop?

• What the Screen Displays: The column shows a percentage (%). For example, 66% means the price stayed safe 66% of the time.

• The "n" Value: The letter n shows how many past trends the script found (for example, 122 past bars).

• "Thin" Warning: If the script finds too few past strong-trend moments, the text will say "thin." This means there is not enough history to trust the percentage.

• Dynamic Tooltips: I added helpful pop-up text boxes! If a user hovers their mouse over the persistence values, a tooltip will appear. This box explains the exact calculation for that specific asset (like DELL) so a user does not have to memorize the rules.

How to Use This for Trading

The main screener score tells a user if the trend is clean today. The new Persistence column tells a user if "clean today" usually means "still trending later" for this specific asset.

Look for the difference between the two:

• High Score but Low Held% (Careful): The asset is moving up very fast today, but historically, it usually crashes quickly. This might be a momentum trap.

• Average Score but High Held% (Safer): The asset is moving normally today, but it has a great history of holding its trend. This is usually a more reliable choice.

Note: This column looks at past history. It is the asset's own record, not a forecast. A high percentage means the asset held its trend well in the past, but every new trade can still break tomorrow.

Why This Update Is Exceptionally Useful

• Prioritizes Survival Over Hype: Replacing the TAR metric with Trend Persistence (Held% · n) is the most valuable change. Traders frequently get wiped out by buying into momentum traps (fast, unsustainable spikes). By showing the historical follow-through of a specific asset, the script helps to manage risk and avoid fake breakouts.

• Accessibility: Complex statistical concepts (like Pearson's R or Logistic Compression) can be overwhelming, especially when English is a second language. The script has Dynamic Tooltips directly on the chart table that teach a user how to read the data in real-time without forcing them to translate a long, external manual.

• Built for Smaller Screens: The script features a Compact Mode in recognition that a significant portion of retail traders globally trade on laptops or single monitors, allowing a user to maximize chart real estate.

• Saves Time Across Timeframes: The Intraday ATR-driven dynamic threshold removes the headache of manual calibration. Traders switching between daily charts and 15-minute charts will appreciate that the script automatically adjusts to lower-timeframe volatility without needing constant tweaking.

Overall, I have built an engine that adapts to market conditions and actively attempts to protect a user from painful trades, all while keeping the interface clean and easy to understand.

Open Source & Free

This script is 100% open source. Users are free to use it, copy the code, and change it (mutate it) to fit thier own trading style. I want everyone to learn from this infrastructure. If someone builds something cool with it, please share it with the community!

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.