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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.