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提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。