OPEN-SOURCE SCRIPT
Fractal Memory Strategy [Jayadev Rana]

Fractal Memory Strategy trades the same engine as the Fractal Memory Projection indicator: it looks for the historical episode most similar to current price action, and only takes trend flips that agree with how that episode played out. Exits scale out at three volatility-adaptive targets.
HOW IT DECIDES
An ATR trailing stop tracks the trend. When it flips, the last 30 closes are converted to normalized log returns and compared against past windows by mean squared distance. The bars that followed the best analog give a net direction; the flip is only traded when the analog direction agrees (the filter can be disabled). Orders are processed on bar close, so no lookahead is involved. For visual context the strategy also draws the 50-candle ghost projection beyond the last bar - it is display-only and never affects order logic.
ENTRIES AND EXITS
On a confirmed bullish flip with agreement the strategy closes any short and enters long; the mirror applies to shorts. One unit of risk R equals ATR times (1.2 plus the ATR percentile rank over 200 bars), so targets and stops widen in volatile regimes and tighten in quiet ones. Position exits: one third at 1R, one third at 2R, the remainder at 3R, with a stop at 1.5R (all adjustable). Direction can be restricted to long-only or short-only.
PROPERTIES USED IN THE PUBLISHED BACKTEST
10,000 initial capital, 10 percent of equity per trade, 0.01 percent commission per order, 2 ticks slippage, no pyramiding, orders on close. These are deliberately conservative; adjust them to match your own broker before drawing any conclusion.
PANEL
Match similarity, volatility regime, forecast direction, closed trade count and win rate.
NOTES
The analog projection is a statistical reference, not a prediction, and past behaviour does not guarantee anything about the future. Results vary by symbol and timeframe; test on your own market with realistic costs before considering any live use. This is an educational tool, not financial advice.
HOW IT DECIDES
An ATR trailing stop tracks the trend. When it flips, the last 30 closes are converted to normalized log returns and compared against past windows by mean squared distance. The bars that followed the best analog give a net direction; the flip is only traded when the analog direction agrees (the filter can be disabled). Orders are processed on bar close, so no lookahead is involved. For visual context the strategy also draws the 50-candle ghost projection beyond the last bar - it is display-only and never affects order logic.
ENTRIES AND EXITS
On a confirmed bullish flip with agreement the strategy closes any short and enters long; the mirror applies to shorts. One unit of risk R equals ATR times (1.2 plus the ATR percentile rank over 200 bars), so targets and stops widen in volatile regimes and tighten in quiet ones. Position exits: one third at 1R, one third at 2R, the remainder at 3R, with a stop at 1.5R (all adjustable). Direction can be restricted to long-only or short-only.
PROPERTIES USED IN THE PUBLISHED BACKTEST
10,000 initial capital, 10 percent of equity per trade, 0.01 percent commission per order, 2 ticks slippage, no pyramiding, orders on close. These are deliberately conservative; adjust them to match your own broker before drawing any conclusion.
PANEL
Match similarity, volatility regime, forecast direction, closed trade count and win rate.
NOTES
The analog projection is a statistical reference, not a prediction, and past behaviour does not guarantee anything about the future. Results vary by symbol and timeframe; test on your own market with realistic costs before considering any live use. This is an educational tool, not financial advice.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。