agentleFS
krzysukrzysu/market-skills/skills/market-trend/SKILL.md

market-trend

Skill3 starsChanged 4 months agoMITView on GitHub

Computes comprehensive trend analysis: EMA alignment (FULL_BULL to FULL_BEAR), HH/HL swing structure detection, slope metrics, and price position. Use for trend direction, strength assessment, and structure integrity. Supports any yfinance ticker.

The file

Files
SKILL.md

market-trend

Comprehensive trend structure analysis combining EMA alignment with swing point pattern recognition.

When NOT to use

  • This is a single indicator (L1), not a trade idea — pair it with market-trend-quality (the L2 health lens) or an L3 strategy before acting.
  • Swing structure lags price by nature — use it for confirmation, not timing. Do not enter on a single EMA cross.
  • Needs 220+ daily candles for EMA(200); with shorter history the long-term read is incomplete (falls back with a warning).

Layering

Two trend skills do overlapping but distinct work. Use them in this order:

  1. market-trend (this skill) — raw EMA alignment + HH/HL structure. Score range -4/+4. Closest to the candles; use as ground truth for direction.
  2. market-trend-quality — structural health (HEALTHY/WEAKENING/DEGRADING). Classifies with sub-signals; the L2 layer that L3 strategies key off. Composes this skill plus market-fibonacci and market-volume internally.

market-trend-analysis (composite trend + RSI + squeeze + volume) was deprecated in favour of market-trend-quality to eliminate the cross-skill conflict that previously fired Pattern U every tick.

Quick Start

uv run skills/market-trend/scripts/run.py AAPL --json

Flags

FlagDefaultNotes
TICKER (positional)—Required. Supports provider:ticker (e.g. hl:LIT, yf:AAPL).
--jsonhumanEmit JSON to stdout.
--source=PROVIDERauto-detectForce a data provider (see README).
--interval=INTERVAL1d1m/2m/5m/15m/30m/1h/2h/4h/8h/12h/1d/3d/1wk/1M.
--period=PERIOD1y1d/5d/1mo/3mo/6mo/1y/2y/5y/10y/ytd/max.

Both timeframe flags are validated — bad values exit 2 with a friendly error. Defaults give daily candles over 1y (~250 bars), enough for EMA(200) and HH/HL swing structure. For intraday (--interval=1h), bump --period to 6mo or 1y; yfinance caps hourly at ~2y and anything sub-hour at ~60d.

What it returns

  • ema_21, ema_50, ema_100, ema_200 — current EMA values
  • alignment — FULL_BULL / PARTIAL_BULL / TANGLED / PARTIAL_BEAR / FULL_BEAR
  • higher_high, higher_low — swing structure booleans (multi-swing majority, see below)
  • slope_21_pct, slope_50_pct — EMA slope as % change over 5 days
  • crossover — golden_cross / death_cross / null
  • price_above_emas — count of EMAs price is above (0–4)
  • score — -4 (strong downtrend) to +4 (strong uptrend)
  • zone — bullish / bearish / neutral
  • signal — STRONG_UPTREND / UPTREND / SIDEWAYS / DOWNTREND / STRONG_DOWNTREND

Swing structure (HH/HL) detection

higher_high and higher_low are determined by majority vote over all detected swing points in the lookback, not by a single prior-swing compare. For a market to register higher_high = True, the most recent swing high must exceed ≥60% of the prior swing highs. Same shape for higher_low. If fewer than 2 swing points are detected on either axis, that field is null.

The swing-detection window scales with the candle interval to avoid spurious swing detection on noisy intraday series:

IntervalSwing window
1m–30m20
1h12
4h8
1d5
1wk4
(other)5 (daily default)

Signal Interpretation

ScoreSignalStructure
+4STRONG_UPTRENDFULL_BULL + HH + HL — maximum conviction
+3UPTRENDFULL_BULL + HH or HL
+2UPTRENDFULL_BULL or PARTIAL_BULL
+1UPTRENDPARTIAL_BULL with improving structure
0SIDEWAYSTANGLED or mixed signals
-1 to -4DOWNTRENDCorresponding bearish structure

Score composition (no slope-agreement bonus — EMA alignment already encodes slope direction):

  • EMA alignment: ±2 (FULL_BULL/FULL_BEAR) or ±1 (PARTIAL_*)
  • HH true: +1, HH false: −0.5
  • HL true: +1, HL false: −0.5
  • Clamped to [-4, +4]

Edge Cases

  • Requires 220+ daily candles for EMA(200); falls back to available EMAs with a warning.
  • Swing structure lags price by nature — best for confirmation, not timing.
  • Golden/death cross events boost/discount score by 1 level.
  • Combine with market-rsi for oversold entries in uptrends, market-volume for confirmation.

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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.