In MagicTradeBot, the next DCA entry price is calculated automatically based on your DCA settings in dca.yaml, total trade budget, and market movement. The calculation ensures that each DCA order is triggered at a strategically spaced price while respecting your capital and risk limits.
🔹 Calculation Overview
Price Deviation Percent
- The bot determines when to place the next DCA order using
price_deviation_percent. - Example: If
price_deviation_percent: 5, the next DCA order triggers when the price moves 5% against your position.
- The bot determines when to place the next DCA order using
Order Size Determination
- Initial order size can be auto-calculated using
auto_calculate_initial_amount: true. The bot considers:
- Account balance (
balance) - Maximum total exposure per trade (
total_percent_investment_per_trade) - Max Orders (
max_orders) - Size Multiplier (
size_multiplier)
- Account balance (
- Initial order size can be auto-calculated using
This ensures that all DCA orders together do not exceed the defined risk and capital allocation.
🔹 Step-by-Step Example
Settings:
auto_calculate_initial_amount: true
balance: 5000
total_percent_investment_per_trade: 2.0 # 2% of balance
max_orders: 3
size_multiplier: 1.5
price_deviation_percent: 5
- Total DCA exposure: 2% of $5000 = $100
- Initial order calculation: $100 ÷ sum of scaled orders (based on multiplier)
Calculation of order sizes:
| Order | Size Calculation | Amount ($) |
|---|---|---|
| Initial | Base size | 26.7 |
| DCA 1 | Previous × size_multiplier | 26.7 × 1.5 = 40.1 |
| DCA 2 | Previous × size_multiplier | 40.1 × 1.5 = 60.1 |
- Next DCA entry price: calculated as a percentage deviation from the last filled order:
| Order | Trigger Price (Long Example) |
|---|---|
| Initial | $20,000 |
| DCA 1 | $20,000 × (1 - 0.05) = $19,000 |
| DCA 2 | $19,000 × (1 - 0.05) = $18,050 |
For short positions, the calculation is mirrored:
- Next order triggers higher than previous by
price_deviation_percent.
- Next order triggers higher than previous by
🔹 Factors Affecting Next DCA Price
Price Deviation Percent (
price_deviation_percent)- Determines spacing between DCA orders.
Order Direction (Long / Short)
- Long → next DCA at lower prices
- Short → next DCA at higher prices
Multiplier & Max Orders
- Ensures the size of each DCA order scales properly without exceeding max orders or budget.
Budget & Risk Limits
- Total DCA exposure capped by
total_percent_investment_per_trade - Prevents over-allocation even if the market keeps moving against you
- Total DCA exposure capped by
🔹 Key Notes
- Applies to manual, signal-based, and auto trades
- Calculation ensures consistent, risk-managed DCA entries
- Works for both long and short trades
- Automatically respects account balance and total exposure limits
🏁 Final Summary
The next DCA entry price in MagicTradeBot is calculated by:
- Determining price movement against your position (
price_deviation_percent) - Scaling DCA order sizes using
size_multiplierandmax_orders - Respecting total investment per trade (
total_percent_investment_per_trade) based on account balance - Adjusting dynamically for long or short positions
This ensures each DCA order is triggered at the optimal price while keeping risk controlled and total exposure within your predefined budget.