Skip to main content

3Commas DCA Bot for TradingView — Setup & Parameter Guide

The 3Commas DCA Bot is a TradingView strategy script that reproduces the behaviour of a 3Commas DCA (Dollar-Cost-Averaging) bot directly on your chart: it opens a deal when your indicator conditions line up, adds safety orders as price moves against you to improve the average entry, and closes the whole deal at a take-profit — with optional stop-loss, trailing take-profit, and breakeven protection. You use it inside TradingView to design and backtest a DCA configuration before running it live.

What this tool is for This is a backtesting and configuration script. It lets you see how a given DCA setup would have behaved on historical data. It does not place live orders by itself. Backtest results are historical and are not a promise of future performance.


1. Add the script to a TradingView chart

  1. Open TradingView and load the chart of the pair you want to test (for example BTCUSDT).

  2. At the bottom of the screen open the Pine Editor tab.

  3. Delete any sample code, then paste the full 3Commas DCA Bot script.

  4. Click Add to chart (top-right of the Pine Editor).

The strategy appears as an overlay on the price chart, and a Strategy Tester panel opens at the bottom with the backtest results.

To change any setting later, hover over the strategy name on the chart and click the gear / Settings icon. The settings dialog has two tabs that matter:

  • Inputs — every parameter described in this guide (deal-start conditions, DCA ladder, take-profit, stop-loss).

  • Properties — account-level backtest assumptions: starting capital, commission, and slippage.


2. Backtest date range

Field

Meaning

From

Tick the box and set a date to start the backtest from that date. Unticked = from the first available bar.

To

Tick the box and set a date to stop the backtest at that date. Unticked = up to the latest bar.

Use this to focus the test on a specific market period (a bull leg, a chop range, a crash) instead of the whole history.

3. Trade direction

A single bot trades one direction, exactly like one 3Commas DCA bot:

  • LONG — buys the base order, adds safety buys below, and takes profit above the average entry. Build oversold / bounce conditions (e.g. RSI below 30).

  • SHORT — sells the base order, adds safety sells above, and takes profit below the average entry. Build overbought conditions.

If you want both directions, run two copies of the strategy — one LONG, one SHORT.

4. Deal-start conditions (Conditions 1–5)

This is the "when do we open a deal" block — the equivalent of the 3Commas Deal start condition builder. There are five condition slots. A deal opens only when every enabled condition is true at the same time: they are combined with AND.

  • Condition 1 is always on — it is the mandatory primary rule and has no enable switch.

  • Conditions 2–5 are optional filters — each has an Enable condition checkbox. A slot that is switched off is ignored (treated as neutral in the AND).

AND logic With RSI < 30 in Condition 1 and (say) a higher-timeframe trend filter in Condition 2, the deal opens only on the bar where both hold. Add more enabled conditions to make entries stricter; disable them to make entries looser.

Fields in each condition slot

Field

What it does

Enable condition

Include this slot in the AND. (Condition 1 has no toggle — always active.)

Indicator

Which indicator drives this condition (see the list below).

Length 1 / 2 / 3

The indicator's period settings. Which of the three is used depends on the indicator — see the mapping table. Unused length boxes are greyed out.

Float param (BB mult / ST factor / SAR increment)

A decimal parameter used only by Bollinger %B (standard-deviation multiplier), Super Trend (factor), and Parabolic SAR (increment). Greyed out for every other indicator.

SAR maximum

The Parabolic SAR maximum acceleration. Active only when the indicator is Parabolic SAR.

MA type

SMA or EMA. Active only when the indicator is Moving Average.

Condition

The operator: Crossing Up, Crossing Down, Greater than, Less than.

Signal value

The level the operator compares the indicator against.

Timeframe

The timeframe the condition is evaluated on. Blank = the chart's timeframe. Set it higher (e.g. 60) to use a higher-timeframe reading of the indicator.

The operators

  • Greater than / Less thanstate checks. True for as long as the indicator sits above / below the signal value. (If a condition is still true right after a deal closes, a new deal can start on the next bar.)

  • Crossing Up / Crossing Downevent checks. True only on the bar the indicator crosses through the signal value.

Indicators and their length mapping

Indicator

Length 1

Length 2

Length 3

Float param

Value that is compared

RSI

period

RSI, 0–100

Ultimate Oscillator

fast (7)

mid (14)

slow (28)

UO, 0–100

MACD

fast (12)

slow (26)

signal (9)

MACD line, plus a zero-cross gate — see note

Stochastic

%K length

%K smoothing

%D smoothing

smoothed %K, and %D for the K/D cross — see note

Bollinger %B

length

std-dev mult (2.0)

%B on a 0–1 scale (≈0 at the lower band, ≈1 at the upper band)

CCI

period

CCI (typically −200…+200)

MFI

period

MFI, 0–100

ADX

DI length (14)

ADX smoothing (14)

ADX, 0–100 (trend strength)

Moving Average

fast length

slow length

fast − slow (with MA type SMA/EMA) — see note

Super Trend

ATR period

factor

close − Super Trend line — see note

Parabolic SAR

increment (0.02)

close − SAR (also uses SAR maximum, default 0.2) — see note

MACD — line and zero-cross gate A long-style MACD entry in 3Commas requires the MACD line to be below zero and to cross up through its signal line. This bot reproduces that: - Crossing Up → the MACD histogram crosses zero (the line crosses its signal) and the MACD line is below the Signal value (use 0). Crossing Down mirrors it (line above the Signal value). - Greater than / Less than → compares the MACD line directly against the Signal value.

Stochastic — %K vs level, or %K crossing %D - Greater than / Less than → compares the smoothed %K against the Signal value (e.g. %K < 20 for oversold). - Crossing Up / Crossing Down%K crosses %D (Length 3 sets the %D smoothing).

Moving Average — two-MA crossover Length 1 is the fast MA, Length 2 the slow MA, and the compared value is fast − slow, so use Signal value 0: - Greater than 0 → fast above slow (bullish trend filter). - Less than 0 → fast below slow (bearish trend filter). - Crossing Up 0 → fast crosses above slow (a bullish entry event). - Crossing Down 0 → fast crosses below slow (a bearish entry event). Set MA type to SMA or EMA.

Super Trend and Parabolic SAR — price vs the line Both return price minus the line, so pair them with Crossing Up / Crossing Down and Signal value 0: crossing up 0 is a bullish flip, crossing down 0 is a bearish flip.

Super Trend is an extra Super Trend is not one of the native 3Commas deal-start indicators — it is included here as a bonus filter. The 3Commas-native set is RSI, Ultimate Oscillator, MACD, Stochastic, Bollinger %B, CCI, MFI, ADX, Moving Average, and Parabolic SAR.

Per-condition timeframe

Each condition can run on its own timeframe via the Timeframe box. A higher-timeframe condition only updates when that timeframe's candle closes — so on a 1-minute chart, a 3-minute RSI steps every 3 minutes. This matches how 3Commas evaluates conditions on closed candles and prevents look-ahead.


5. DCA settings (the safety-order ladder)

Once a deal is open, safety orders average the position as price moves against you. This block defines the ladder.

Field

Meaning

Averaging approach

Arithmetic or Geometric — how the price steps between safety orders are spaced (see below).

Base order size ($)

The size of the first (base) order that opens the deal.

Safety order size ($)

The size of the first safety order.

Deviation to open SO1 (%)

How far below the base price (for a long) the first safety order sits.

Deviation step multiplier

How much wider each successive step is than the last. 1 = evenly spaced; 2 = each gap doubles.

Safety order size multiplier

How much larger each safety order is than the previous one. 1 = all equal; 1.5 = each is 1.5× the last.

Max safety orders

How many safety orders the ladder can place (0–30).

Arithmetic vs Geometric spacing

Both modes use the same Deviation to open SO1 and Deviation step multiplier inputs; only the spacing formula differs. Using the defaults (deviation 1%, step multiplier 2, 5 safety orders), the cumulative distance of each safety order from the base price is:

Mode

SO1

SO2

SO3

SO4

SO5

Arithmetic (default)

−1%

−3%

−7%

−15%

−31%

Geometric

−2%

−3.96%

−5.88%

−7.76%

−9.61%

Arithmetic is the cumulative-additive ladder 3Commas uses — it spreads safety orders far apart at the deep end. Geometric compounds a constant percentage step and stays much tighter. They are almost identical when the step multiplier is 1 and diverge as it grows. Default is Arithmetic.

Reading the ladder on the chart When a deal is open, each safety order is drawn as a grey SO1…SOn label at its limit price, so you can see the whole grid.


6. Take profit

Field

Meaning

Take profit (%)

The profit target, as a percentage.

TP calculated from

Average Order — target measured from the deal's average entry (moves as safety orders fill; this is the usual DCA behaviour). Base Order — target measured from the base-order price only (fixed).

Trailing take profit

When on, instead of closing at the fixed target the bot lets profit run and trails a stop behind the peak.

Trailing pullback (%)

How far price may retrace from its best level before the trailing take-profit closes the deal. Only used when Trailing take profit is on.

With Average Order anchoring, every safety order that fills lowers the average entry (for a long) and pulls the take-profit price down with it, so the deal can complete on a smaller bounce.

7. Stop loss

Field

Meaning

Use stop loss

Turn the stop-loss on. Off by default — a pure DCA bot relies on the safety ladder rather than a stop.

Stop loss (%)

Distance of the stop from the base-order price. It should sit beyond the last safety order (see the limit below).

Move SL to breakeven

When on, once the deal is far enough in profit the stop is moved up to the average entry so the deal can no longer lose.

Breakeven activation (%)

How far in profit (from the base price) the deal must go before the stop jumps to breakeven. Only used when Move SL to breakeven is on.

The stop-loss must sit beyond the averaging grid A DCA stop-loss placed inside the safety-order ladder would trigger before the deepest safety orders can fill — which the DCA logic does not allow. If your Stop loss (%) is smaller than the deepest safety order's deviation, the strategy stops opening new deals and shows a red banner at the top of the chart telling you the minimum stop-loss value to use.

With the default arithmetic ladder the deepest safety order sits at −31%, so the minimum stop-loss is about 31.04%. Switching to the tighter geometric ladder lowers that minimum to about 9.65%. Either raise the stop-loss beyond the grid, or tighten the ladder, to clear the warning.

8. Properties tab (backtest assumptions)

These are set in the Properties tab of the settings dialog, not the Inputs tab:

  • Initial capital — the starting balance for the backtest (default 1000).

  • Commission — trading fee per order (default 0.05% per order).

  • Slippage — modelled fill slippage (default 0).

Set these to match the exchange you intend to trade so the backtest result is realistic.


9. Reading the chart

While a deal is open the script draws four lines:

  • Base price (silver) — where the deal opened.

  • Average entry (aqua) — the current average price of all filled orders; this is what the take-profit is usually measured from.

  • Take profit (green) — the current profit target (or the trailing stop when trailing is on).

  • Stop / trail (magenta) — the active stop-loss or trailing level.

Grey SO1…SOn labels mark each safety-order limit price.

10. Notes and limits

  • Evaluation on closed candles. Conditions are checked on confirmed (closed) candles, matching 3Commas and avoiding look-ahead.

  • Multi-timeframe. A higher-timeframe condition updates only on that timeframe's candle close.

  • State vs event. Greater/Less than stay true while the condition holds, so a new deal can start on the next bar if the condition is still true after a deal closes. Crossing operators fire once per crossing.

  • One direction per bot. LONG or SHORT — run two copies for both.

  • Backtest only. The script models the DCA logic for testing on historical data. Numbers in the Strategy Tester are historical and not a forecast.


This guide describes the 3Commas DCA Bot TradingView script as configured in its published version. If a field on your screen does not match this guide, you may be on a different version of the script.

Did this answer your question?