OPEN-SOURCE SCRIPT

Continuous Accumulation Strategy [DCA] v9

118
🇬🇧 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.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.