OPEN-SOURCE SCRIPT
ForgeQuant AI | Regime + LSTM + R:R [MarketFragments]

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
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
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.