How is the next DCA entry price calculated?

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

  1. 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.
  2. 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)

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.

๐Ÿ”น Factors Affecting Next DCA Price

  1. Price Deviation Percent (price_deviation_percent)

    • Determines spacing between DCA orders.
  2. Order Direction (Long / Short)

    • Long โ†’ next DCA at lower prices
    • Short โ†’ next DCA at higher prices
  3. Multiplier & Max Orders

    • Ensures the size of each DCA order scales properly without exceeding max orders or budget.
  4. Budget & Risk Limits

    • Total DCA exposure capped by total_percent_investment_per_trade
    • Prevents over-allocation even if the market keeps moving against you

๐Ÿ”น 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:

  1. Determining price movement against your position (price_deviation_percent)
  2. Scaling DCA order sizes using size_multiplier and max_orders
  3. Respecting total investment per trade (total_percent_investment_per_trade) based on account balance
  4. 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.

๐Ÿ“Ž Related Topics