OPEN-SOURCE SCRIPT
RedFlag: Dynamic Step DCA Strategy

Based on RedFlag idea from HamsterBot guys.
RedFlag: Dynamic Step DCA is a grade Dollar Cost Averaging (DCA) tool designed to capitalize on market corrections. Instead of trying to catch the exact bottom, this strategy uses a system of Safety Orders (SO) to systematically lower your Average Entry Price as the market drops.
Unlike simple linear DCA bots, this strategy features a Dynamic Geometric Grid. This means you can configure the distance between buy orders to expand with every step, allowing you to cover significantly deeper market drawdowns without exhausting your capital on minor fluctuations.
Key Features
⚙️ Settings & Configuration Guide
Here is a detailed explanation of every parameter in the settings menu:
1. Entry Settings
2. Safety Orders (Averaging) Settings
This is the core engine of the strategy.
Safety Order Step %: The distance required for the first Safety Order (DCA buy) after the initial entry.
Safety Order Step Scale: The "Elasticity". This multiplier determines how the grid expands.
- 1.0: Linear Grid. Every buy order is spaced equally (e.g., -1%, -1%, -1%).
- 1.2 - 1.5: Geometric Grid (Recommended). Each step becomes wider.
Example (Scale 1.5): Step 1 is 1%, Step 2 is 1.5%, Step 3 is 2.25%. This saves capital for deeper drops.
Calculate SO from Avg Price:
☑ ON: The next buy level is calculated from your Average Position Price. This is a "Moving Grid" that chases the price down efficiently.
☐ OFF: The next buy level is calculated from the original Source Price (Static Grid).
Max Safety Orders Count: The maximum number of additional buys allowed. This protects you from buying indefinitely during a market crash.
3. Exit Settings
Take Profit %: The profit target.
Important: This is always calculated from your Average Position Price, not the first entry price. This allows you to close the deal in profit even if the price never returns to the all-time high.
RedFlag: Dynamic Step DCA is a grade Dollar Cost Averaging (DCA) tool designed to capitalize on market corrections. Instead of trying to catch the exact bottom, this strategy uses a system of Safety Orders (SO) to systematically lower your Average Entry Price as the market drops.
Unlike simple linear DCA bots, this strategy features a Dynamic Geometric Grid. This means you can configure the distance between buy orders to expand with every step, allowing you to cover significantly deeper market drawdowns without exhausting your capital on minor fluctuations.
Key Features
- Smart Entry: Places a Limit Order below the current price to catch "wicks" and immediate dips.
- Dynamic Grid Expansion: The distance between Safety Orders can increase exponentially (e.g., 1% -> 1.5% -> 2.25%), allowing you to survive high volatility.
- Moving Target Logic: Safety orders can be calculated based on your Average Position Price, meaning the grid adapts to your actual break-even point.
- Auto-Take Profit: The exit target automatically adjusts as your average price lowers, ensuring you exit with a profit on the first significant rebound.
⚙️ Settings & Configuration Guide
Here is a detailed explanation of every parameter in the settings menu:
1. Entry Settings
- Source Price: The price data used for calculations (Default: Close).
- Base Order Drop %: The "Trigger". The strategy places the very first Buy Limit order this many percent below the current price. Example: If set to 1.0% and price is $100, the bot waits to buy at $99.
2. Safety Orders (Averaging) Settings
This is the core engine of the strategy.
Safety Order Step %: The distance required for the first Safety Order (DCA buy) after the initial entry.
Safety Order Step Scale: The "Elasticity". This multiplier determines how the grid expands.
- 1.0: Linear Grid. Every buy order is spaced equally (e.g., -1%, -1%, -1%).
- 1.2 - 1.5: Geometric Grid (Recommended). Each step becomes wider.
Example (Scale 1.5): Step 1 is 1%, Step 2 is 1.5%, Step 3 is 2.25%. This saves capital for deeper drops.
Calculate SO from Avg Price:
☑ ON: The next buy level is calculated from your Average Position Price. This is a "Moving Grid" that chases the price down efficiently.
☐ OFF: The next buy level is calculated from the original Source Price (Static Grid).
Max Safety Orders Count: The maximum number of additional buys allowed. This protects you from buying indefinitely during a market crash.
3. Exit Settings
Take Profit %: The profit target.
Important: This is always calculated from your Average Position Price, not the first entry price. This allows you to close the deal in profit even if the price never returns to the all-time high.
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.