OPEN-SOURCE SCRIPT
Holy Grail

This is a long-only educational strategy that simulates what happens if you keep adding to a position during pullbacks and only exit when the asset hits a new All-Time High (ATH). It is intended for learning purposes only — not for live trading.
🧠 How it works:
You can adjust:
📊 Intended assets & timeframes:
This strategy is designed for broad market indices and long-term appreciating assets, such as:
Use it only on 1D or higher timeframes — it’s not meant for scalping or short-term trading.
⚠️ Important Limitations:
This is not a performance strategy. It’s a teaching tool to show that:
🎓 Why it exists:
The purpose of this strategy is to demonstrate market psychology and risk overconfidence. Traders often chase strategies with high win rates without considering holding time, drawdowns, or opportunity cost.
This script helps visualize that phenomenon.
🧠 How it works:
- The strategy identifies pullbacks using a simple moving average (MA).
- When price dips below the MA, it begins monitoring for the first green candle (close > open).
- That green candle signals a potential bottom, so it adds to the position.
- If price goes lower, it waits for the next green candle and adds again.
- The exit happens after ATH — it sells on each red candle (close < open) once a new ATH is reached.
You can adjust:
- MA length (defines what’s considered a pullback)
- Initial buy % (how much to pre-fill before signals start)
- Buy % per signal (after pullback green candle)
- Exit % per red candle after ATH
📊 Intended assets & timeframes:
This strategy is designed for broad market indices and long-term appreciating assets, such as:
- SPY, NASDAQ, DAX, FTSE
Use it only on 1D or higher timeframes — it’s not meant for scalping or short-term trading.
⚠️ Important Limitations:
- Long-only: The script does not short. It assumes the asset will eventually recover to a new ATH.
- Not for all assets: It won't work on assets that may never recover (e.g., single stocks or speculative tokens).
- Slow capital deployment: Entries happen gradually and may take a long time to close.
- Not optimized for returns: Buy & hold can outperform this strategy.
- No slippage, fees, or funding costs included.
This is not a performance strategy. It’s a teaching tool to show that:
- High win rate ≠ high profitability
- Patience can be deceiving
- Many signals = long capital lock-in
🎓 Why it exists:
The purpose of this strategy is to demonstrate market psychology and risk overconfidence. Traders often chase strategies with high win rates without considering holding time, drawdowns, or opportunity cost.
This script helps visualize that phenomenon.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.