OPEN-SOURCE SCRIPT
Continuous Accumulation Strategy [DCA] v9

🇬🇧 English: Continuous Accumulation Strategy [DCA] v9.4
This script is a full-featured strategy designed to backtest the "Buy the Dip" or "Dollar Cost Averaging" (DCA) philosophy. Its core feature is the Dynamic Peak Detection logic, which solves the "lock-in" problem of previous versions. Instead of getting stuck on an old high, the strategy constantly adapts to the market by referencing the most recent peak.
Key Features
* Dynamic Peak Detection: You define the "Peak Lookback Period." For example, on a Daily chart, setting it to `5` references the peak of the last business week.
* Stable Order Management: The strategy consistently uses a fixed cash amount (e.g., $100) for each entry, which prevents any runtime errors related to negative equity.
* Publishing-Ready: To meet TradingView's requirement for a backtest report, this strategy executes a symbolic, one-time "dummy trade" (one buy and one sell) at the very beginning of the test period. This first trade should be ignored when analyzing performance, as its only purpose is to enable publication.
How It Works
The main logic follows an adaptive cycle: Find Dynamic Peak -> Wait for a Drop -> Buy on Crossover -> Repeat.
1. Finds the Dynamic Peak: On every bar, it identifies the highest price within your defined lookback period.
2. Calculates the Drop: It constantly calculates the percentage drop from this moving peak.
3. Executes an Entry: The moment the price crosses below a target drop percentage, it executes a buy order.
4. Continuously Adapts: As the price moves, the dynamic peak is constantly updated, meaning the strategy never gets locked and is always ready for the next opportunity.
How to Use This Strategy
* Focus on the Strategy Tester: After adding it to the chart, analyze the Equity Curve, Net Profit, and Max Drawdown to see how this accumulation philosophy would have performed on your favorite asset.
* Optimize Parameters: Adjust the "Peak Lookback Period" and "Drop Percentages" to fit the volatility of the asset you are testing.
This is a tool for testing and analyzing a "buy and accumulate" philosophy. Its main logic does not generate sell signals.
This script is a full-featured strategy designed to backtest the "Buy the Dip" or "Dollar Cost Averaging" (DCA) philosophy. Its core feature is the Dynamic Peak Detection logic, which solves the "lock-in" problem of previous versions. Instead of getting stuck on an old high, the strategy constantly adapts to the market by referencing the most recent peak.
Key Features
* Dynamic Peak Detection: You define the "Peak Lookback Period." For example, on a Daily chart, setting it to `5` references the peak of the last business week.
* Stable Order Management: The strategy consistently uses a fixed cash amount (e.g., $100) for each entry, which prevents any runtime errors related to negative equity.
* Publishing-Ready: To meet TradingView's requirement for a backtest report, this strategy executes a symbolic, one-time "dummy trade" (one buy and one sell) at the very beginning of the test period. This first trade should be ignored when analyzing performance, as its only purpose is to enable publication.
How It Works
The main logic follows an adaptive cycle: Find Dynamic Peak -> Wait for a Drop -> Buy on Crossover -> Repeat.
1. Finds the Dynamic Peak: On every bar, it identifies the highest price within your defined lookback period.
2. Calculates the Drop: It constantly calculates the percentage drop from this moving peak.
3. Executes an Entry: The moment the price crosses below a target drop percentage, it executes a buy order.
4. Continuously Adapts: As the price moves, the dynamic peak is constantly updated, meaning the strategy never gets locked and is always ready for the next opportunity.
How to Use This Strategy
* Focus on the Strategy Tester: After adding it to the chart, analyze the Equity Curve, Net Profit, and Max Drawdown to see how this accumulation philosophy would have performed on your favorite asset.
* Optimize Parameters: Adjust the "Peak Lookback Period" and "Drop Percentages" to fit the volatility of the asset you are testing.
This is a tool for testing and analyzing a "buy and accumulate" philosophy. Its main logic does not generate sell signals.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。