This strategy simulates a dollar-cost averaging (DCA) trading bot that enters positions when a short moving average crosses over or under a long moving average.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
152 lines of Pine Script v5 from 3Commas Visible DCA Strategy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
3Commas Visible DCA Strategy manages trades by placing scaled safety orders as price drops, lowering the average position entry price. Exits occur when reaching a target profit percentage or hitting a stop loss percentage. Primary input settings allow adjustments to moving average types and periods, base and safety order sizes, target profit, stop loss, and DCA scaling parameters. It plots directly on the main price chart.
Moving average cross entry signals
Dollar cost averaging safety orders
Configurable safety order volume and step scale
Percentage-based target profit and stop loss exits
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Strategy
string
Long
Strategy
Profit currency
string
Quote (USDT)
Profit_currency
Base order Size
int
10
Base_order_size
Safety order Size
int
20
Safety_order_size
Entry at Cross Over / Under
string
Over
Triger_Type
Short Moving Average
string
SMA
Short_Moving_Average
Period
int
5
Short_Period
Long Moving Average
string
HMA
Long_Moving_Average
Period
int
50
Long_Period
Target profit (%)
float
1.5
Target_profit
Stop Loss (%)
int
15
Stop_Loss
Max safety trades count
int
10
Max_safety_trades_count
Show all 15 settings
Setting
Type
Default
Variable
Price deviation to open safety orders (% from initial order)
float
0.4
Price_deviation
Safety order volume scale
float
1.8
Safety_order_volume_scale
Safety order step scale
float
1.19
Safety_order_step_scale
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This strategy plots Bollinger Bands on the price chart with adjustable length, standard deviation, and offset. It defines buy and sell zones using candle size percentage and body size thresholds. Long positions enter when the lower zone is breached without con
The Mean Reversion Strategy Template calculates a baseline mean using SMA, EMA, or VWAP alongside upper and lower deviation bands based on standard deviation, ATR, or percentage offsets. It generates long and short entries when price touches, bounces from, or
This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po
This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov
This strategy combines multi-timeframe RSI analysis with exponential moving average filters to execute trades on price bounces. It evaluates daily and weekly RSI levels alongside pip-distance thresholds between fast, slow, and long-term EMAs. Position entries
This strategy plots on the price chart and trades fair value gaps filtered by RSI and two EMAs. It opens a long when a bullish gap, a rising candle, RSI below the oversold level, and price under both EMAs align, and a short on the opposite conditions. Each tra