OPEN-SOURCE SCRIPT
Fractal Memory Projection [Jayadev Rana]

Fractal Memory Projection searches price history for the moment that most resembles the present, then shows what happened next - drawn on your chart as 50 lighter ghost candles ahead of the current bar - together with trend-flip BUY and SELL signals and volatility-adaptive targets.
HOW THE FORECAST WORKS
The last 30 closes are converted to normalized log returns (the pattern window). The script scans up to 750 past bars and scores every historical window of the same length by mean squared distance, so the comparison is about the shape of movement, not price level. The bars that followed the best match are replayed forward from the current close, rescaled by the ratio of current ATR to ATR at the match, and drawn as 50 semi-transparent ghost candles beyond the last bar. The panel reports the match similarity, how many bars ago it occurred, and the net forecast direction.
The projection is a statistical analog - a look at how the most similar past episode unfolded - not a prediction or a guarantee. It is display-only and never affects historical values, so nothing repaints.
BUY AND SELL SIGNALS
An ATR trailing stop tracks the trend. When it flips direction, a BUY or SELL label prints - by default only when the ghost-candle forecast agrees with the flip direction (toggle available). Alerts are included for both signals.
VOLATILITY-ADAPTIVE TARGETS
Target spacing is not fixed. A unit of risk R equals ATR multiplied by (0.8 + ATR percentile rank over 200 bars), so quiet markets produce tighter targets and volatile markets produce wider ones. Each signal sets TP1, TP2 and TP3 at 1R, 2R and 3R and a stop loss at 1.2R (adjustable). Only the most recent trade's levels are kept on the chart to stay clean.
PANEL
Match quality percent, bars since the match, volatility regime (Low, Normal, High), forecast direction, and current trend side.
SETTINGS
Pattern window, scan depth, forecast length, ghost candle colors, ATR length, trail multiplier, forecast-agreement filter, stop multiplier, and panel position are all configurable.
NOTES
Works on any symbol and timeframe with enough history (at least scan depth plus forecast length bars). This is an analysis tool, not financial advice. Test on your own data and manage risk before trading.
HOW THE FORECAST WORKS
The last 30 closes are converted to normalized log returns (the pattern window). The script scans up to 750 past bars and scores every historical window of the same length by mean squared distance, so the comparison is about the shape of movement, not price level. The bars that followed the best match are replayed forward from the current close, rescaled by the ratio of current ATR to ATR at the match, and drawn as 50 semi-transparent ghost candles beyond the last bar. The panel reports the match similarity, how many bars ago it occurred, and the net forecast direction.
The projection is a statistical analog - a look at how the most similar past episode unfolded - not a prediction or a guarantee. It is display-only and never affects historical values, so nothing repaints.
BUY AND SELL SIGNALS
An ATR trailing stop tracks the trend. When it flips direction, a BUY or SELL label prints - by default only when the ghost-candle forecast agrees with the flip direction (toggle available). Alerts are included for both signals.
VOLATILITY-ADAPTIVE TARGETS
Target spacing is not fixed. A unit of risk R equals ATR multiplied by (0.8 + ATR percentile rank over 200 bars), so quiet markets produce tighter targets and volatile markets produce wider ones. Each signal sets TP1, TP2 and TP3 at 1R, 2R and 3R and a stop loss at 1.2R (adjustable). Only the most recent trade's levels are kept on the chart to stay clean.
PANEL
Match quality percent, bars since the match, volatility regime (Low, Normal, High), forecast direction, and current trend side.
SETTINGS
Pattern window, scan depth, forecast length, ghost candle colors, ATR length, trail multiplier, forecast-agreement filter, stop multiplier, and panel position are all configurable.
NOTES
Works on any symbol and timeframe with enough history (at least scan depth plus forecast length bars). This is an analysis tool, not financial advice. Test on your own data and manage risk before trading.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
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.