Detailed Guide: How the DCA Bot Works

Table of Contents

1. Overall Model

The bot follows a classic DCA (Dollar-Cost Averaging) model: it opens a position with a Base Order (BO), then, if price drops, buys more in stages via Safety Orders (SOs) to lower the average entry price, and exits using one or more take-profit/stop-loss mechanisms running in parallel.

Each trading pair (symbol) is managed by its own independent worker loop, scanning conditions every 0.5 seconds: buy conditions are checked first, then sell conditions, in that exact sequential order on every iteration.

2. Lifecycle of a Trade

[Waiting for buy signal] -> BASE ORDER filled
        |
        v
[Holding a position] ---- price drops ----> SAFETY ORDER 1, 2, ... (if enabled)
        |
        +- price rises enough -> TAKE PROFIT (Static / Dynamic / Trailing)
        |
        +- price drops to threshold -> STOP LOSS (Static / Dynamic)
        |
        v
[Position fully closed] -> state reset -> back to step 1

An important point to grasp before reading the sections below: every buy/sell order in the bot is reactive. The bot does not pre-place any resting orders on the exchange order book. It continuously watches the price, and only once a condition is detected as met does it submit a LIMIT order priced exactly at the market price observed at that moment (deliberately, so it fills immediately, accepting the Taker role). This applies to both buy orders (BO/SO) and LIMIT sell orders used for take profit (Static TP, Dynamic TP).

3. Buying Process

3.1. Base Order: entry conditions

The bot only buys a Base Order when all enabled technical indicators are satisfied at the same time (a logical AND, not OR):

IndicatorBuy condition
RSIrsi_min < RSI < rsi_oversold (default: 20 < RSI < 30)
MAShort-term MA crosses above long-term MA (ma_short > ma_long)
MACDMACD line above the Signal line
ADXADX > adx_threshold and +DI > -DI (uptrend strong enough)
Bollinger BandsCurrent price touches or is below the lower band
VolumeTrading volume exceeds the configured threshold

Important note: if you do not enable any indicator, the bot will buy the Base Order immediately once the capital condition is met, without waiting for any technical signal. This is deliberate behavior, and the bot will send a one-time alert when it detects this situation.

3.2. How buy orders are placed and tracked

  1. The bot places a LIMIT BUY order priced exactly at the market price observed at the moment it decides to buy (not using Post-Only, to avoid the exchange rejecting the order; it accepts filling immediately as a Taker).
  2. After placing the order, the bot waits up to 120 seconds, checking fill status every 3 seconds.
  3. If the price is still close to the order's price (within 0.2%), the bot extends the wait by another 60 seconds, up to 5 extensions (about 7 minutes total).
  4. If the price has moved away from the order's price without filling, the bot cancels the order and, if the buy signal is still valid, retries at a new price for the remaining unfilled amount.
  5. If the order is only partially filled before being cancelled, the filled portion is still fully recorded into the position; only the unfilled portion is retried.

3.3. Safety Orders (DCA): lowering the average entry price

When price drops after the Base Order, the bot buys more in configured SO tiers:

4. In-Depth Analysis of Technical Indicators

This section covers the meaning, strengths/weaknesses, and practical usage of each indicator the bot supports.

4.1. RSI (Relative Strength Index)

4.2. MA (Moving Average) crossover

4.3. MACD

4.4. ADX + DI (Average Directional Index)

4.5. Bollinger Bands

4.6. Volume

4.7. Closed candle vs. open/live candle

The use_closed_candle_only parameter determines whether the bot calculates indicators on fully closed candles or on the candle currently forming (live).

Closed candles only (default, True) Allow using the live candle (False)
Pros Stable signals, no "repainting" of values; RSI/MA/MACD values are final. Reacts faster, may catch an entry point earlier during a sharp move.
Cons Always lags real price action by up to one full candle. "Flickering" signals risk entry based on an unstable state.

5. Selling Process

The bot has 5 exit mechanisms, each can be toggled independently and they run in parallel.

5.1. Static Take Profit: fixed staged profit-taking

Split into 3 levels, TP1, TP2, and TP3, each selling a portion of the position according to configured percentages. The actual sell amount is always capped by the real quantity currently held, ensuring the position is never stuck with leftover coins after all 3 tiers have triggered, as long as tp3_sell_percent is kept high enough (100% is safe).

If a tier's calculated amount comes out below 5.5 USDT (under the exchange's minimum), the bot automatically merges that portion into the next tier.

5.2. Dynamic Take Profit: profit-taking based on ATR volatility

The take-profit level is calculated dynamically: entry price + (ATR x atr_tp_multiplier). If Static TP is also enabled at the same time, Dynamic TP is completely locked out until TP3 (static) has triggered. If Static TP is disabled, Dynamic TP operates independently from the start.

5.3. Trailing Take Profit: profit-taking based on the price peak

Instead of selling at a fixed price, Trailing TP follows the price upward to maximize profits during strong pumps.

Example (Min Profit = 2.0%, Trailing TP = 1.0%):
  1. Activate: The bot waits until the price reaches +2.0% profit. It does NOT sell yet.
  2. Track Peak: As the price climbs, the exit trigger moves up with it, always staying exactly 1.0% below the highest peak.
  3. Exit: When the price peaks and drops exactly 1.0%, the bot instantly executes a MARKET SELL to close the position, letting you ride the full wave.

⚠️ WARNING: MARKET ORDER FEES & SLIPPAGE

Trailing TP uses a MARKET SELL order to ensure immediate execution when the price drops.
  1. The Risk: Min Profit does NOT account for exchange trading fees (typically 0.1%-0.2%) and market slippage. If set too low (e.g., 0.1% or 0.2%), your net return could be NEGATIVE (a loss) after fees.
  2. Recommendation: Always set Min Profit to >= 0.5% to guarantee a positive net profit after all costs are covered.

5.4. Static Stop Loss & 5.5. Dynamic Stop Loss

Sells the entire position with a MARKET order when price drops to either the fixed percentage (Static) or the ATR-based level (Dynamic). The bot cuts the loss as soon as either condition is hit first. There is no Trailing Stop Loss feature.

5.6. Panic Sell: manual emergency exit

The user presses a button to immediately sell an open position with a MARKET order. If you select a specific pair, it sells only that pair. If no pair is selected, it triggers a 'Panic Sell All' for your entire active portfolio. After a successful Panic Sell, that pair is automatically paused to prevent the bot from immediately buying back in.

5.7. Isolation: removing a position from automatic DCA

Allows you to "isolate" a currently held position out of the DCA management system and set a manual target sell price. The position moves to a separate tracking list, checked every 5 minutes, freeing the bot to resume trading that pair from scratch whenever a new signal appears.

6. What Happens When Multiple Mechanisms Are Combined

6.1. Take Profit triggering permanently locks out Safety Orders

Because every Safety Order is placed reactively, there is no SO order sitting on the exchange to "cancel". Instead, a state flag is set. If any TP tier has ever triggered, the bot will not buy more to lower the average price even if the price reverses sharply. This avoids a conflict between "currently taking profit" and "currently averaging down a loss".

6.2. Static TP + Dynamic TP

Static TP always takes absolute priority. With the default configuration (tp3_sell_percent = 100%), the position is always fully sold at TP3, so in practice Dynamic TP never gets a chance to run. Recommendation: if you choose Static TP, disable Dynamic TP entirely.

6.3. Dynamic TP + Trailing TP

Dynamic TP only sells dynamic_tp_sell_percent% once the ATR-based TP level is reached, and hands the remainder to Trailing TP, which continues tracking the price peak.

6.4. Trailing TP + Stop Loss

Because Trailing TP has the constraint of "never selling at a loss", in a scenario where price rises slightly then drops sharply, Stop Loss (if enabled) is the only line of defense preventing the position from losing further.

6.5. Consecutive losses automatically pause a pair for 24 hours

When a pair reaches 3 consecutive stop-loss exits, the bot automatically pauses trading for that pair for 24 hours from the most recent loss, then automatically resumes.

7. Minimum Order Size & Dust Handling

8. Supporting Features

9. Reliability & State Recovery

10. Full Configuration Parameter Table

ParameterDefaultMeaning
capital100.0USDT capital allocated to this pair's Base Order
interval15mCandle timeframe used for indicator calculations
use_closed_candle_onlyTrueOnly calculate indicators on closed candles (avoids noise mid-candle)
use_rsi / rsi_period / rsi_min / rsi_oversoldTrue / 14 / 20 / 30RSI zone condition allowing a buy
use_ma / ma_short_period / ma_long_periodFalse / 9 / 21Moving average crossover condition
use_macdFalseMACD crossing above Signal condition
use_adx / adx_period / adx_thresholdFalse / 14 / 25Trend strength condition (+DI > -DI is hardcoded)
use_bollinger / bollinger_period / bollinger_stdFalse / 20 / 2.0Price touching the lower Bollinger band condition
use_volume / volume_thresholdFalse / 150.0Minimum trading volume condition
max_safety_orders2Maximum number of Safety Order tiers
safety_order_steps[1.0, 2.0]Percentage drop to trigger each SO tier
safety_order_volume_scale1.0Multiplier applied to capital to get each SO's size
use_static_tpTrueEnable/disable fixed staged profit-taking
tp1_percent / tp1_sell_percent2.0 / 40.0Profit level % and sell % at TP1
tp2_percent / tp2_sell_percent4.0 / 50.0Profit level % and sell % at TP2
tp3_percent / tp3_sell_percent6.0 / 100.0Profit level % and sell % at TP3
use_dynamic_tpFalseEnable/disable ATR-based profit-taking
atr_tp_multiplier2.0ATR multiplier used to calculate the dynamic profit-taking level
dynamic_tp_sell_percent50.0Sell % at Dynamic TP (only meaningful when Trailing TP is also enabled)
use_trailing_tpFalseEnable/disable peak-based profit-taking
trailing_take_profit_percent1.0Percentage price is allowed to pull back from the peak before selling
min_profit_percent0.5Minimum required profit before Trailing TP or Dynamic TP is allowed to sell
use_static_sl / static_sl_percentFalse / 5.0Fixed-percentage stop loss
use_dynamic_sl / stop_loss_atr_multiplierFalse / 2.0ATR-based stop loss
atr_period14ATR calculation period (shared by Dynamic TP and Dynamic SL)

11. Current Limitations to Be Aware Of

These are architectural characteristics users should know before trading with significant capital:

  1. No SO orders are pre-placed on the exchange order book. The bot detects and places orders reactively (polling every 0.5 seconds), so during extremely fast price moves, it is possible to miss an SO level if price sweeps through it and recovers within under a second.
  2. Every buy order and every LIMIT take-profit sell order is priced at the current market price to guarantee an immediate fill, meaning they almost always execute as a Taker, incurring higher fees than resting orders would (Maker).

Prioritizing Taker orders results in slightly higher transaction fees for the user. However, in the architecture of an automated trading bot (especially a DCA grid), the practice of holding orders internally on the server and only executing Taker orders when conditions are met is not a sign of poor programming; rather, it is a deliberate trade-off made to secure the following four critical strategic advantages:

3. Once any Take Profit tier has triggered, Safety Orders are permanently locked out for that position, so the remaining position after a partial profit-take is not any better protected against subsequent adverse moves, beyond whatever Stop Loss you may have enabled.

12. How to Use: Isolate, Backtest, Panic Sell

12.1. Panic Sell: manual emergency exit

When to use it: you want to exit one or all open positions immediately, regardless of what the indicators/TP/SL are currently saying.

Steps:

  1. Select the pair you want to exit from the list on the left. If no pair is selected, it triggers a 'Panic Sell All' for your entire active portfolio.
  2. Click the PANIC SELL button.
  3. Confirm the warning dialog that appears.
  4. The bot immediately sends a MARKET SELL order for the entire quantity held of that pair.

Things to note after clicking it:

12.2. Isolate: removing a position from automatic DCA management

When to use it: you want to "shelve" a position that is losing money, freeing the bot to resume trading that pair from scratch whenever a new signal appears.

Steps to isolate a position:

  1. On the real-time status table, right-click the row of the pair you want to isolate.
  2. Select "Isolate this pair" from the menu that appears.
  3. Confirm the dialog. Note the warning: this pair will stop DCA entirely.
  4. Enter the target sell price (USDT). By default the bot suggests a starting reference of current market price x 1.05.
  5. If you enter a target price lower than or equal to the current market price, the bot will show a separate warning: doing so will cause the position to be sold immediately with a MARKET order.

12.3. Backtest: simulating a strategy on historical data

When to use it: before turning on a new configuration with real money, you want to estimate how it would have performed based on actual historical price data.

Steps:

  1. Select the pair you want to test from the list on the left.
  2. Click the BACKTEST button.
  3. In the dialog that appears, choose the time period and the simulated capital (USDT).
  4. Click "LOAD DATA & START BACKTEST".
  5. The results appear as a detailed log per trade, ending with a summary: total net profit (after an assumed round-trip fee of 0.2% per buy-sell cycle), number of complete buy-sell cycles, win rate, and total number of filled orders (including both Base Order and Safety Orders).

Key points to understand before trusting the backtest results:

This document will be updated whenever the bot's architecture changes.