OPEN-SOURCE SCRIPT

ForgeQuant AI | Regime + LSTM + R:R [MarketFragments]

728
ForgeQuant AI [MarketFragments]

A regime-aware overlay that combines four systems into a single read on the
chart: a regime classifier, a deep recurrent LSTM-style memory cell, a 0-100
confluence edge score, and a dynamic ATR-based risk/reward engine.

Important up front: this is a research preview. It has NOT been forward tested,
and no performance claims are made. See the notes at the bottom.

─────────────────────────────────────────────────────────────
HOW IT WORKS
─────────────────────────────────────────────────────────────

STEP 1 -- REGIME DETECTION
Volatility percentile (ATR rank) and a directional-movement trend-strength
reading classify each bar into one of six regimes: Strong Trend Bull, Strong
Trend Bear, High-Vol Chop, Mean Reversion, Breakout Potential, or Neutral. The
chart background shades to match.

STEP 2 -- DEEP LSTM MEMORY CELL
A 2-layer recurrent memory cell processes an engineered input vector built from
normalized volume, momentum vs the 21 EMA, volatility-of-volatility, and RSI
deviation. Layer 1 runs a fast cell and a slow cell; Layer 2 is a stacked
context cell. Gate weights adapt online via a clipped, momentum-smoothed
pseudo-BPTT update, with optional attention-weighted readout and layer-norm
input scaling. The cell outputs a hidden state, a confidence reading, a regime
bias (via an adaptive bias band), and an anomaly flag when price behavior
diverges sharply from the learned state.

This is a heuristic recurrent filter written in Pine -- not a trained neural
network. Treat it as an adaptive smoother, not a forecast.

STEP 3 -- CONFLUENCE EDGE SCORE
A 0-100 score blends five inputs: market structure (fair-value gaps and volume
absorption), volume behavior, momentum (RSI and the 9 EMA), higher-timeframe
trend (60-minute), and the LSTM bias/anomaly state.

STEP 4 -- DYNAMIC RISK & REWARD
Suggested risk % scales by regime (reduced in chop, trimmed further on an
anomaly). Stop and target are ATR multiples, with the target stretched by LSTM
confidence. A forward-projected R:R cloud draws the target (green) and stop
(red) zones from the latest close.

─────────────────────────────────────────────────────────────
SIGNALS
─────────────────────────────────────────────────────────────

Long Edge score >= 62, RSI > 52, a bullish FVG or absorption bar, and no
active LSTM anomaly.
Short Edge score >= 62, RSI < 48, a bearish FVG or absorption bar, and no
active LSTM anomaly.

Triggers evaluate on confirmed bars only.

─────────────────────────────────────────────────────────────
WHAT YOU SEE
─────────────────────────────────────────────────────────────

Background shade Current regime
Cyan line LSTM hidden state plotted around price (× ATR amplitude)
Green/Red cloud Dynamic R:R -- target (green) and stop (red)
Triangles Long (L, up) and Short (S, down) signals
Dashboard panel Regime, edge score, LSTM confidence, suggested risk %,
dynamic R:R, anomaly status, attention split, bias band
Gate plots Optional forget/input/output gate activations (debug)

─────────────────────────────────────────────────────────────
SETTINGS
─────────────────────────────────────────────────────────────

Display Regime background, panel position/size, diagnostics, gates
LSTM Memory Cell Enable, memory speed, anomaly sensitivity, attention,
layer-norm, hidden-state plot amplitude
Regime-Bias Band Auto (stdev-scaled) vs manual, sensitivity, lookback,
floor/ceiling
Dynamic Risk Base risk %, ATR stop/target multiples, chop multiplier,
R:R cloud toggle and forward extend

─────────────────────────────────────────────────────────────
IMPORTANT NOTES
─────────────────────────────────────────────────────────────

-- This indicator has NOT been backtested or forward tested
-- No performance claims are made
-- Shared as a research tool for community review
-- Risk, stop, and target values are illustrative sizing suggestions, not
trade instructions
-- Results will vary by instrument, timeframe, and market conditions
-- This is not financial advice
-- Trading involves substantial risk of loss
-- Past results do not guarantee future performance
-- Use for educational and research purposes only

─────────────────────────────────────────────────────────────
Free for public use

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.