Spot DCA (Martingale)

Published on Apr 27, 2023Updated on Nov 5, 20249 min read

Introduction to OKX Spot DCA (Martingale) bot

The Martingale strategy is commonly used in situations such as forex and futures trading. Futures DCA is a trading bot that uses the Martingale strategy for futures trading. It allows traders to automate their trades based on these principles.

What is the difference between dollar-cost averaging (DCA) and Martingale strategy

Dollar-cost averaging (DCA) is an asset management strategy. It involves splitting one-off positions at multiple price levels to get a better average entry price when the market moves against the initial trade, and exiting the trade when the take profit target has been met.Martingale is one form of DCA.

Martingale is a trading strategy based on the concept of doubling the trading size after every loss. With a doubled position size each time after losses, the size of the next profitable trade will exceed the combined losses of all previous trades with additional profit. In simple terms, if you lose a trade, you double your next trade to recover your losses and hope to make a profit.

The Martingale strategy may potentially earn long-term growth by taking the fluctuating profit from cycles of rebound (if trading in a long direction), or correction (with short direction), with the aim to minimize losses on the overall purchase.

How does OKX Spot DCA (Martingale) bot work?

Users begin the trading cycle by selecting their risk profile via a series of parameters (or choosing from conservative, moderate, and aggressive pre-set parameters).

The strategy will start with an initial order that is programmed to execute a certain number of times. If the asset price drops by a designated percentage, the bot will execute a second trade that's a multiple of the first order. This cycle is repeated until the price reaches the maximum order count, the take profit level, or the stop loss level, as defined by the user. If the take profit target is reached, then the bot will run the next trading cycle.

Traders who believe the price of an asset will increase in the future tend to use this strategy to increase the size of their position — even if it is temporarily declining in value. They use the DCA approach to buy when they think the price is low and sell when they think it’s high.

For that reason, they tend to use it during volatile (significant but short-lived movements) markets, as well as in sideways markets they think will experience short-term rebounds.

How to get started

Web: Navigate to Trade, select Trading bots - Marketplace, and click Spot DCA (Martingale).

spot grid 1
spot dca 1

App: Navigate to Trade, select Trading bots, and press Spot DCA (Martingale).

spot dca 2

Enter parameters manually, copy lead traders' bots, or use backtested AI parameters, and confirm the total investment amount to create a Spot DCA (Martingale) bot (After you create a bot, the initial funds will be isolated from your Trading account and used for bot trading only).

Setup Options

futures dca 4
  • Set myself: Set parameters based on your own analysis of the market.

  • Set myself — Auto fill: Automatically fill in parameters recommended by the trading bot, based on backtested strategy.

  • AI strategy: Use the parameters recommended by backtested strategy (these parameters are based on a weekly backtest of this pair).

  • Lead bots: Copy lead traders' winning bots on the Marketplace in one-click.

DCA Trading Parameters

spot dca 2-1
  1. Price steps: Percentage difference between two consecutive safety orders, denominated in quote currency.

  2. TP target per cycle: When the TP price is triggered and the order is fully filled, the bot will end the current cycle index and start the next one as specified.

  3. Initial order margin: First order initiated by the DCA bot at the start of each trading cycle.

  4. Safety order margin: Safety orders will trade incrementally in each trading cycle, to lower the average cost of the trading pairs being traded, and help to achieve the take profit target faster.

  5. Max safety orders: The maximum number of safety orders that can be placed in a trading cycle. Actual number of placed safety orders may be determined by your margin situation.

  6. Amount multiplier: Applied to the investment amount for placing the next safety order. It affects the aggressiveness in averaging the entry prices of your investments. For example, with a safety order amount = 100 USDT, multiplier = 2. Safety orders will be placed:

    1. 100 = (2^0 × 100)

    2. 200 = (2^1 × 100)

    3. 400 = (2^2 × 100), et cetera

  7. Price steps multiplier: Applied to the price step for placing the next safety order. It increases or decreases the price gap between safety orders. For example, with a price step = 1%, multiplier = 2. Safety orders will be placed when the price changes:

    1. 1% = (0 + 1 × 2^0)%

    2. 3% = (1 + 1 × 2^1)%

    3. 7% = (3 + 1 × 2^2)%, et cetera

Managing your Spot DCA (Martingale) bot

Web: Head to OKX Trading Bots homepage, and select 'My bots'. You will be brought to a Bot Dashboard where you can manage your running bots.

bot management 1
spot dca 3

App: Head to OKX Trading Bots homepage, and select 'My bots'. You will be brought to the "My bots" page where you can manage your running bots.

bot management 2

DCA bot management features

spot dca 4
  1. Stop your bot: When you stop this bot, the system will cancel all pending orders and sell your crypto at market price. Funds from the sale will be returned to your trading account.

  2. Details: View more details about your running bot by accessing the Bot Details page.

  3. Replicate parameters: One-click set-up to recreate your running bot with the same parameters.

  4. Display order lines: View the details of your running bot's unfilled orders per cycle on the chart.

Case study

spot dca 5
  • Trading Pair: BTC/USDT (Assuming current price is 25,000 USDT)

  • Price steps: 2%

  • TP target per cycle: 5%

  • Max safety orders: 2

Running the Bot

Stage 1 – initial order placement: The system creates a new DCA cycle and calculates the price of each safety order from the price of the initial order (25,000 USDT), according to the predefined price step (2%) set by the user, for instance, 24,500 USDT, 23,750 USDT, etc. The system will also calculate the take profit (TP) price from the initial order, for instance, 26,250 USDT, which will be the TP order of the DCA bot.

BTC price (USDT)

Price step (%) / TP target %

Average price / Profit (USDT)

$25,000

-- (Initial order)

$25,000

$24,500

-2% (Safety order #1)

$24,750

$23,750

-4% (Safety order #2)

$24,166.67

$26,250

+5% (Take Profit target)

$26,250 - $24,166.67 = $2,083.33

Stage 2 – bot operation: The bot initially buys one BTC position at 25,000 USDT. If the price of BTC drops 2% to 24,500 USDT, the bot will automatically buy another at this lower price point, bringing the average entry price of the two positions to 24,750 USDT. If the price drops an additional 4% to 23,750 USDT, the bot will buy another position, bringing the average entry price of the three positions to 24,166.67 USDT.

Now, if the price of BTC bounces back to 25,375 USDT and reaches your 5% take-profit order, the bot will sell all three positions for a profit and then start a new cycle.

Risk reminder and notes

  1. Risks related to market condition: Using this strategy, the amount spent on trading can increase rapidly and reach a high value after just a few transactions. This is exacerbated if the price of an asset continues to fall for a prolonged period of time. If a trader continues to double their trades, the probability of loss is infinite. If a trader runs out of funds and exits the trade while using the strategy, the losses faced can be quite high. In addition, the risk-to-reward ratio may not be reasonable for every trader. While using the strategy, higher amounts are spent with every loss until a win, and the final result may only be to break even. Further, if an asset continues to fall in value, there is a chance it could fall to zero, in which case the entire value of the trader's holdings would be lost. It is important to be aware of the risks involved and to have a solid risk management plan in place. For example, it is important to set up stop-loss orders to limit potential losses.