market-trend-quality
Skill3 starsChanged 4 months agoMITView on GitHub
Assesses trend health by composing L1 indicators: EMA alignment, HH/HL integrity, pullback depth, impulse vs retrace ratio, and volume confirmation on impulse bars. Classifications: HEALTHY_UPTREND, HEALTHY_DOWNTREND, WEAKENING, DEGRADING, TANGLED.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- beadsSkill
- backtest-engineSkill
- backtest-pipelineSkill
- backtest-trend-minerSkill
- bug-scanSkill
- daily-trade-pickSkill
- execution-kraken-perpsSkill
- execution-kraken-spotSkill
- l3-conviction-scanSkill
- market-accumulationSkill
- market-basisSkill
- market-breadthSkill
- market-breakoutSkill
- market-emaSkill
- market-exhaustionSkill
- market-fibonacciSkill
- market-liquidity-sweepSkill
- market-macdSkill
- market-macroSkill
- market-moversSkill
- market-notesSkill
- market-overviewSkill
- market-rsiSkill
- market-snapshotSkill
- market-squeezeSkill
- market-s-rSkill
- market-stateSkill
- market-trendSkill
- market-valuationSkill
- market-volatilitySkill
- market-volumeSkill
- market-watchlistSkill
- portfolio-mgmtSkill
- position-watchdogSkill
- risk-engineSkill
- run-all-l2Skill
- run-all-l3Skill
- run-watchlistSkill
- strategy-accumulation-swingSkill
- strategy-breakout-confirmSkill
- strategy-exhaustion-fadeSkill
- strategy-fitness-heatmapSkill
- strategy-funding-carrySkill
- strategy-liquidity-sweepSkill
- strategy-mean-reversionSkill
- strategy-trend-followSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Do not enter off a WEAKENING / DEGRADING / TANGLED classification — those say structure is breaking down, not that a reversal trade exists.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
market-trend-quality
L2 pattern detection skill that composes L1 indicators to assess the health and quality of a trend.
When NOT to use
- This is pattern detection, not a trade idea — treat
HEALTHY_UPTREND/WEAKENINGas input to an L3 strategy (strategy-trend-follow) orrun-all-l3, not as an entry. - Do not enter off a
WEAKENING/DEGRADING/TANGLEDclassification — those say structure is breaking down, not that a reversal trade exists. - For raw EMA alignment + HH/HL structure use
market-trend; this skill is the health lens L3 strategies key off, not a standalone signal.
Layering
This is the only L2 trend skill after the consolidation:
market-trend(L1) — raw EMA alignment + HH/HL structure (closest to candles)market-trend-quality(this skill, L2) — structural health — what L3 strategies key off
market-trend-analysis was deprecated in favour of this skill to eliminate the cross-skill conflict that fired Pattern U every tick.
Schema invariants:
pattern.presentis True iffpattern.classificationis non-None- The 4-sub fallback (line 202 of
lib.py) ensures 4+ present sub-signals always classifies, even whensigned_score< 0.75 — a deep pullback can drag signed_score below threshold while the directional signal is still strong. - The 3-sub branch (line 207 of
lib.py) catches 3 present sub-signals withweighted_sum > 0.30. - HEALTHY_UPTREND requires
trend_score >= 3ANDhh_intact=TrueANDema_bullish=True. If any of those fail, classifier cascades to WEAKENING / DEGRADING / TANGLED.
Quick Start
uv run skills/market-trend-quality/scripts/run.py SPY
uv run skills/market-trend-quality/scripts/run.py SPY --jsonFlags
| Flag | Default | Notes |
TICKER (positional) | — | Required. Supports provider:ticker (e.g. hl:LIT, yf:AAPL). |
--json | human | Emit JSON to stdout. |
--source=PROVIDER | auto-detect | Force a data provider (see README). |
--interval=INTERVAL | 1d | 1m/2m/5m/15m/30m/1h/2h/4h/8h/12h/1d/3d/1wk/1M. |
--period=PERIOD | 1y | 1d/5d/1mo/3mo/6mo/1y/2y/5y/10y/ytd/max. |
Both timeframe flags are validated — bad values exit 2 with a friendly error. For intraday (--interval=1h), bump --period to 6mo or 1y; yfinance caps hourly at ~2y and anything sub-hour at ~60d.
Sub-signals
| Sub-signal | Weight | Source L1 | Logic |
| EMA alignment | 0.25 | market-trend | alignment field: FULL_BULL, FULL_BEAR, etc. |
| HH/HL integrity | 0.25 | market-trend | higher_high and higher_low both intact for uptrend, both broken for downtrend |
| Pullback depth (shallow vs deep) | 0.20 | market-trend + market-fibonacci | Compare price distance to fib support levels to gauge retracement depth |
| Impulse vs retrace ratio | 0.15 | derived from candles | 6-bar recent return vs 6-bar prior return, normalized by ATR(14). Bounce (recent > 0, prior < 0) → +0.15; decline-decel (recent > 0, prior > 0, recent < abs(prior)) → −0.075. Requires an actual reversal for the bullish path — continued selling at a slower pace does not count as a bounce. |
| Volume confirmation | 0.15 | market-volume | High volume + OBV rising → +0.15; high volume + OBV falling → −0.15 (distribution); quiet accumulation (vr in [0.7, 1.5] with OBV rising or price > EMA50) → +0.075; low volume + OBV falling → −0.15. |
Classifications
| Classification | Meaning |
| HEALTHY_PULLBACK_UPTREND | Healthy uptrend in pullback phase — bullish EMA alignment, recent bounce off the lows, price back above EMA50. Entry: bounce confirmation. |
| HEALTHY_UPTREND | Strong uptrend with score >= 3, intact HH/HL, and bullish EMA alignment |
| HEALTHY_DOWNTREND | Strong downtrend with score <= -3, broken HH/HL, and bearish EMA alignment |
| WEAKENING | Trend score 1-2 or -1 to -2 with conflicting sub-signals. Also used as a fallback when the sub-signal sum is strongly directional (≥0.75 / ≤−0.75) but the L1 trend_score didn't reach the HEALTHY_* gate — ensures pattern.present is never false when sub-signals are strongly aligned. Also fires for 3 present sub-signals with weighted_sum > 0.30 (mirrors the bug-scan Shape #1 trigger and the ALGO 4h liquidity-sweep fix). |
| DEGRADING | HH/HL structure breaking down and EMA alignment becoming tangled |
| TANGLED | No clear alignment or directional conviction |
HEALTHY_PULLBACK_UPTREND is checked first (before HEALTHY_UPTREND) — if the conditions are met, it wins regardless of the underlying trend_score.
Output
pattern.present(bool)pattern.confidence(1–5)pattern.classification(HEALTHY_PULLBACK_UPTREND / HEALTHY_UPTREND / HEALTHY_DOWNTREND / WEAKENING / DEGRADING / TANGLED)pattern.typealways"TREND_QUALITY"signals— per-signal{"present": bool, "weight": float}input_scores— raw L1 outputsnarrative— one-sentence explanation
Output envelope (AXI)
--json output follows the canonical AXI envelope — {data, count, errors, help[]}. Default schema is the per-skill minimal fields (3-6 essentials); pass --fields=<csv> to project or --full for the full payload. count is the item count, help[] is contextual next-step command templates. Lib.py return shapes (L1Result / L2Result / L3Result / L3Idea / RegimeSignal) are unchanged — the envelope wraps them at the scripts/run.py boundary.
Home view (no-arg mode)
No-arg mode prints the home view from $XDG_DATA_HOME/market-skills/<skill>_last.json (last successful run). Errors are not cached.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

