OPEN-SOURCE SCRIPT

Argus Gaze: Attention Trend Engine [forexobroker]

353
# Argus Gaze: Attention Trend Engine [forexobroker]

🔶 OVERVIEW

Argus Gaze brings the attention mechanism — the core idea behind modern transformer models — onto your chart. Instead of asking "what does an indicator formula say about this bar?", it asks a different question: "when did the market last LOOK like this, and what happened next?"

Every bar is encoded as a compact, ATR/z-normalized state vector. A soft-attention head then compares today's state against the last N historical states, weights each one by similarity (softmax over negative distance), and blends their KNOWN follow-up returns into a single forward-looking Trend Score. Because every feature is volatility-normalized, the same settings behave consistently across forex, indices, futures, and crypto.

What makes it different from pattern-matching scripts: attention is SOFT. It never picks one "best match" — it weighs all N analogues at once, and it tells you how focused that weighting is. The attention entropy becomes a conviction gauge: when attention collapses onto a handful of strongly similar past states, conviction is high; when attention is spread thin, the engine is honest about its uncertainty.

The second half of the script is a full prop-firm risk engine: FTMO / Topstep / Apex presets, ATR-based position sizing, simulated R tracking, daily-loss lockout, trailing max-drawdown breach detection, a consistency cap on signals per day, plus session and news-blackout filters. The chart literally tints orange and the dashboard reads STAND DOWN when you should not be clicking buttons.

🔶 ALGORITHM

1. State encoding — each bar becomes a 3-feature vector, all volatility-normalized:
• f1 = (close − close[1]) / ATR(14) — directional thrust
• f2 = (high − low) / ATR(14) − 1 — range expansion vs. average
• f3 = volume z-score over a 50-bar window (guarded when stdev = 0)
2. Similarity — for each lag k = 1..N (default 64), the squared Euclidean distance d²ₖ between today's vector and the vector k bars ago is computed.
3. Attention logits — simₖ = −d²ₖ / temperature. Temperature controls sharpness: low = spiky attention on the closest analogues, high = smooth blending.
4. Stable softmax — a first pass finds the maximum logit; a second pass computes wₖ = exp(simₖ − maxSim) so the exponentials can never overflow.
5. Known outcomes — each historical state carries the ATR-normalized return that followed it: outₖ = (close[k−1] − close[k]) / ATR(14)[k].
6. Forecast — the attention-weighted average Σ(wₖ · outₖ) / Σwₖ, i.e. "what the market did the last times it looked like this", in ATR units.
7. Trend Score — an EMA (default 5) of the forecast.
8. Conviction — attention entropy −Σ pₖ·ln(pₖ), normalized by ln(N) to [0,1]; conviction = 1 − entropy. The Attention Focus label shows the top-3 lags the head is "looking at" plus the effective number of analogues (1/Σp²).

🔶 SIGNAL LOGIC

• BUY — Trend Score crosses above +threshold (default 0.08) with conviction above the floor.
• SELL — Trend Score crosses below −threshold with the same conviction requirement.
• Every signal must additionally pass: signal cooldown (default 5 bars), position-state filter (no stacked same-direction signals), optional HTF EMA(21) trend confirm (last confirmed HTF bar, lookahead off — non-repainting), session filter, news blackout, prop-firm lockout, and the max-signals-per-day consistency cap.
• All signals are evaluated on confirmed bars only (barstate.isconfirmed) — no repainting.
• On each signal the script draws the entry (gold), stop (dashed) and target (dashed) lines with size, SL and TP labels; the last 3 trade line-sets are kept on chart (configurable).

🔶 PROP FIRM ENGINE

Presets load the firm's headline limits; your Risk per Trade % input always rules sizing.

| Preset | Daily Loss | Max Drawdown | Suggested Risk |
|---------|-----------|------------------|----------------|
| FTMO | 5.0% | 10.0% | 1.0% |
| Topstep | 2.0% | 4.0% | 0.5% |
| Apex | 2.5% | 5.0% (trailing) | 0.5% |
| Custom | your input | your input | your input |

• Sizing — risk$ = account × risk%. SL distance = ATR(14) × multiplier (default 1.5). Contracts = risk$ / (SL distance × point value); forex symbols are converted to standard lots, futures/stocks shown as whole contracts.
• Simulated R tracking — one simulated trade at a time at the signal price; each confirmed bar checks SL before TP (conservative). A loss books −1R, a win books +R:R (default +2R) into the daily ledger.
• Daily lockout — when daily R reaches −(daily loss % / risk per trade %), signals stop and the chart background turns orange until the next session day.
• Trailing DD breach — cumulative R is tracked against its peak; if the drawdown in R exceeds the preset's max-drawdown budget, status flips to DD BREACH and signals stop.
• Consistency cap — Max Signals / Day (default 5); the counter resets on each new session day.

🔶 INPUTS

• Algorithm — Attention Lookback N (16–200), Softmax Temperature, Score Smoothing EMA, Volume Z-Score Window.
• Signal Logic — Score Threshold, Conviction Floor, Signal Cooldown Bars, HTF Trend Confirm + HTF Timeframe.
• Prop Firm Rules — Preset (FTMO/Topstep/Apex/Custom), Account Size $, Risk per Trade %, three Custom limit inputs, Max Signals / Day.
• Sessions & News — Session Filter (Off/London/New York/RTH Futures/Custom), Custom Session, News Blackout toggle + two news windows.
• Trade Management — Stop Loss ATR multiple, Reward:Risk, Trade Line Length, Keep Last N Trade Drawings.
• Visual — Dashboard, 3-Layer Signal Glow, Trend Baseline Ribbon, Attention Focus Label, and all colors.

🔶 ALERTS

Webhook-ready alert() JSON fires on every buy/sell close with action, ticker, price, SL, TP, size and daily R. Ten named alert conditions:

1. AGZ Buy
2. AGZ Sell
3. AGZ Any Signal
4. AGZ Regime Bull (score crosses above zero)
5. AGZ Regime Bear (score crosses below zero)
6. AGZ High Conviction (conviction exceeds 50%)
7. AGZ Lockout (daily-loss or drawdown limit hit)
8. AGZ Session Open
9. AGZ Daily Reset
10. AGZ Webhook JSON (placeholder-based JSON payload)

🔶 LIMITATIONS

• Attention finds analogues, not certainties. "What happened after similar states" is a statistical tendency — it is NOT a prediction guarantee, and regimes with no good historical analogue produce low-conviction, low-quality readings.
• The simulated R ledger is indicative only: it fills at the signal close, ignores spread, slippage, commissions and gaps, and resolves SL-before-TP inside a bar. It is a discipline gauge, not broker P&L — your real account ledger always rules.
• Position sizing relies on syminfo.pointvalue; for CFDs and some exotic symbols verify the suggested size against your broker's contract specification before trading.
• Session and news windows use the chart symbol's exchange timezone; adjust the windows when trading symbols on other exchanges.
• On very short lookbacks or illiquid symbols the volume z-score feature degrades (stdev guard returns 0); the engine still works on the two price features.
• Signals are confirmed-bar only by design, so they appear at the close of the signal bar, never intrabar.
• This is an analysis tool, not financial advice. Past behavior of similar market states does not guarantee future results.

🔶 RELEASE NOTES

v1.0 — Initial release. Soft-attention trend engine (stable softmax, entropy-based conviction, top-3 attention focus readout), prop-firm risk engine with FTMO/Topstep/Apex/Custom presets, simulated R ledger with daily lockout and trailing DD breach, session + news filters, HTF confirm, trade line-sets, 12-row dashboard, webhook JSON alerts and 10 alert conditions.

#ftmo

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。