OPEN-SOURCE SCRIPT

EvoTrend-X Indicator — Evolutionary Trend Learner Experimental

87
EvoTrend-X Indicator — Evolutionary Trend Learner


NOTE: This is an experimental Pine Script v6 port of a Python prototype. Pine wasn’t the original research language, so there may be small quirks—your feedback and bug reports are very welcome. The model is non-repainting, MTF-safe (lookahead_off + gaps_on), and features an adaptive (fitness-based) candidate selector, confidence gating, and a volatility filter.




What it is

EvoTrend-X is adaptive trend indicator that learns which moving-average length best fits the current market. It maintains a small “population” of fast EMA candidates, rewards those that align with price momentum, and continuously selects the best performer. Signals are gated by a multi-factor Confidence score (fitness, strength vs. ATR, MTF agreement) and a volatility filter (ATR%). You get a clean Fast/Slow pair (for the currently best candidate), optional HTF filter, a fitness ribbon for transparency, and a themed info panel with a one-glance STATUS readout.

Core outputs
• Selected Fast/Slow EMAs (auto-chosen from candidates via fitness learning)
• Spread cross (Fast – Slow) → visual BUY/SELL markers + alert hooks
• Confidence % (0–100): Fitness ⊕ Distance vs. ATR ⊕ MTF agreement
• Gates: Trend regime (Kaufman ER), Volatility (ATR%), MTF filter (optional)
• Candidate Fitness Ribbon: shows which lengths the learner currently prefers
• Export plot: hidden series “EvoTrend-X Export (spread)” for downstream use



Why it’s different
• Evolutionary learning (on-chart): Each candidate EMA length gets rewarded if its slope matches price change and penalized otherwise, with a gentle decay so the model forgets stale regimes. The best fitness wins the right to define the displayed Fast/Slow pair.
• Confidence gate: Signals don’t light up unless multiple conditions concur: learned fitness, spread strength vs. volatility, and (optionally) higher-timeframe trend.
• Volatility awareness: ATR% filter blocks low-energy environments that cause death-by-a-thousand-whipsaws. Your “why no signal?” answer is always visible in the STATUS.
• Preset discipline, Custom freedom: Presets set reasonable baselines for FX, equities, and crypto; Custom exposes all knobs and honors your inputs one-to-one.
• Non-repainting rigor: All MTF calls use lookahead_off + gaps_on. Decisions use confirmed bars. No forward refs. No conditional ta.* pitfalls.



Presets (and what they do)
• FX 1H (Conservative): Medium candidates, slightly higher MinConf, modest ATR% floor. Good for macro sessions and cleaner swings.
• FX 15m (Active): Shorter candidates, looser MinConf, higher ATR% floor. Designed for intraday velocity and decisive sessions.
• Equities 1D: Longer candidates, gentler volatility floor. Suits index/large-cap trend waves.
• Crypto 1H: Mid-short candidates, higher ATR% floor for 24/7 chop, stronger MinConf to avoid noise.
• Custom: Your inputs are used directly (no override). Ideal for systematic tuning or bespoke assets.



How the learning works (at a glance)
1. Candidates: A small set of fast EMA lengths (e.g., 8/12/16/20/26/34). Slow = Fast × multiplier (default ×2.0).
2. Reward/decay: If price change and the candidate’s Fast slope agree (both up or both down), its fitness increases; otherwise decreases. A decay constant slowly forgets the distant past.
3. Selection: The candidate with highest fitness defines the displayed Fast/Slow pair.
4. Signal engine: Crosses of the spread (Fast − Slow) across zero mark potential regime shifts. A Confidence score and gates decide whether to surface them.



Controls & what they mean

Learning / Regime
• Slow length = Fast ×: scales the Slow EMA relative to each Fast candidate. Larger multiplier = smoother regime detection, fewer whipsaws.
• ER length / threshold: Kaufman Efficiency Ratio; above threshold = “Trending” background.
• Learning step, Decay: Larger step reacts faster to new behavior; decay sets how quickly the past is forgotten.

Confidence / Volatility gate
• Min Confidence (%): Minimum score to show signals (and fire alerts). Raising it filters noise; lowering it increases frequency.
• ATR length: The ATR window for both the ATR% filter and strength normalization. Shorter = faster, but choppier.
• Min ATR% (percent): ATR as a percentage of price. If ATR% < Min ATR% → status shows BLOCK: low vola.

MTF Trend Filter
• Use HTF filter / Timeframe / Fast & Slow: HTF Fast>Slow for longs, Fast<Slow for shorts. Keeps trades aligned with the larger tide.

Visuals & Diagnostics
• Theme: Auto/Light/Dark (panel text adapts).
• Regime background: Green/red wash in trending regimes.
• Show HTF EMAs: Adds transparent HTF Fast/Slow overlays for context.
• Candidate Fitness Ribbon: A two-row table: candidate length + color-coded fitness (warmer = stronger).
• Info Panel: Best Fast, ER, ATR%, HTF OK, Regime (“Trending/Chop”), Confidence % (with heat), and the effective cfg values (MinConf, ATR len, Min ATR%).
• Gate toggles (optional): Tiny dots at pane bottom for VOL OK, HTF OK, CONF OK.

Export
• Export selected spread (hidden): Hidden series “EvoTrend-X Export (spread)” to feed other scripts via input.source.



How to use (recipes)

1) EURUSD, 1H (swing bias)
• Preset: FX 1H (Conservative).
• Gate: MinConf 65–75; Min ATR% ≈ 0.10–0.20.
• Flow: Trade spread cross up only when Regime = Trending, VOL OK, HTF OK, and Confidence ≥ MinConf.
• Tactic: Hold while spread remains ↑ and ER stays > threshold; exit when spread flips or Confidence decays below your comfort zone.

2) FX index/majors, 15m (active intraday)
• Preset: FX 15m (Active).
• Gate: MinConf 60–70; Min ATR% 0.15–0.30.
• Flow: Focus on session opens (LDN/NY). The ribbon should heat up on shorter candidates before valid crosses appear—good early warning.

3) SPY / Index futures, 1D (positioning)
• Preset: Equities 1D.
• Gate: MinConf 55–65; Min ATR% 0.05–0.12.
• Flow: Use spread crosses as regime flags; add timing from price structure. For adds, wait for ER to remain trending across several bars.

4) BTCUSD, 1H (24/7)
• Preset: Crypto 1H.
• Gate: MinConf 70–80; Min ATR% 0.20–0.35.
• Flow: Crypto chops—volatility filter is your friend. When ribbon and HTF OK agree, favor continuation entries; otherwise stand down.



Reading the Info Panel (and fixing “no signals”)

The panel is your self-diagnostic:
• HTF OK? False means the higher-timeframe EMAs disagree with your intended side.
• Regime: If “Chop”, ER < threshold. Consider raising the threshold or waiting.
• Confidence: Heat-colored; if below MinConf, the gate blocks signals.
• ATR% vs. Min ATR%: If ATR% < Min ATR%, status shows BLOCK: low vola.
• STATUS (composite):
• BLOCK: low vola → increase Min ATR% down (i.e., allow lower vol) or wait for expansion.
• BLOCK: HTF filter → disable HTF or align with the HTF tide.
• BLOCK: confidence → lower MinConf slightly or wait for stronger alignment.
• OK → you’ll see markers on valid crosses.



Alerts

Two static alert hooks:
• BUY cross — spread crosses up and all gates (ER, Vol, MTF, Confidence) are open.
• SELL cross — mirror of the above.
Create them once from “Add Alert” → choose the condition by name.



Exporting to other scripts

In your other Pine indicators/strategies, add an input.source and select EvoTrend-X → “EvoTrend-X Export (spread)”. Common uses:
• Build a rule: only trade when exported spread > 0 (trend filter).
• Combine with your oscillator: oscillator oversold and spread > 0 → buy bias.



Best practices
• Let it learn: Keep Learning step moderate (0.4–0.6) and Decay close to 1.0 (e.g., 0.99–0.997) for smooth regime memory.
• Respect volatility: Tune Min ATR% by asset and timeframe. FX 1H ≈ 0.10–0.20; crypto 1H ≈ 0.20–0.35; equities 1D ≈ 0.05–0.12.
• MTF discipline: HTF filter removes lots of “almost” trades. If you prefer aggressive entries, turn it off and rely more on Confidence.
• Confidence as throttle:
• 40–60%: exploratory; expect more signals.
• 60–75%: balanced; good daily driver.
• 75–90%: selective; catch the clean stuff.
• 90–100%: only A-setups; patient mode.
• Watch the ribbon: When shorter candidates heat up before a cross, momentum is forming. If long candidates dominate, you’re in a slower trend cycle.



Non-repainting & safety notes
• All request.security() calls use lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on.
• No forward references; decisions rely on confirmed bar data.
• EMA lengths are simple ints (no series-length errors).
• Confidence components are computed every bar (no conditional ta.* traps).



Limitations & tips
• Chop happens: ER helps, but sideways microstructure can still flicker—use Confidence + Vol filter as brakes.
• Presets ≠ oracle: They’re sensible baselines; always tune MinConf and Min ATR% to your venue and session.
• Theme “Auto”: Pine cannot read chart theme; “Auto” defaults to a Dark-friendly palette.



Publisher’s Screenshots Checklist

1) FX swing — EURUSD 1H
• Preset: FX 1H (Conservative)
• Params: MinConf=70, ATR Len=14, Min ATR%=0.12, MTF ON (TF=4H, 20/50)
• Show: Clear BUY cross, STATUS=OK, green regime background; Fitness Ribbon visible.

ảnh chụp nhanh

2) FX intraday — GBPUSD 15m
• Preset: FX 15m (Active)
• Params: MinConf=60, ATR Len=14, Min ATR%=0.20, MTF ON (TF=60m)
• Show: SELL cross near London session open. HTF lines enabled (translucent).
• Caption: “GBPUSD 15m • Active session sell with MTF alignment.”

ảnh chụp nhanh

3) Indices — SPY 1D
• Preset: Equities 1D
• Params: MinConf=60, ATR Len=14, Min ATR%=0.08, MTF ON (TF=1W, 20/50)
• Show: Longer trend run after BUY cross; regime shading shows persistence.
• Caption: “SPY 1D • Trend run after BUY cross; weekly filter aligned.”

ảnh chụp nhanh


4) Crypto — BINANCE:BTCUSDT 1H
• Preset: Crypto 1H
• Params: MinConf=75, ATR Len=14, Min ATR%=0.25, MTF ON (TF=4H)
• Show: BUY cross + quick follow-through; Ribbon warming (reds/yellows → greens).
• Caption: “BTCUSDT 1H • Momentum break with high confidence and ribbon turning.”

ảnh chụp nhanh

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.