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
197 lines of Pine Script v4 from utils/dca_strategy_template.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
DCA Bot Backtest initiates a base order immediately or based on indicator inputs, then scales into positions with safety orders as price deviates against the entry, applying configurable volume and step scale multipliers. Exits occur when the position reaches a defined target profit percentage calculated from the average position price. It plots directly on the price chart. Stop-loss logic is disabled by default, meaning deals rely on price recovery to exit.
Safety order scaling with volume and step multipliers
Support for long and short bot directions
Average entry price profit target exits
Flexible deal start conditions including external indicators
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Bot Type
string
Long
botType
Base Order Size
float
100
baseOrder
Safety Order Size
float
200
safetyOrder
Max safety order count
float
5
maxSafetyOrders
Price deviation in % to open safety orders
float
3
priceDeviation
Safety Order volume scale
float
1.1
volumeScaleInput
Safety Order step scale
float
1.2
safetyOrderStepScale
Target profit (%)
float
2
targetProfit
Start Time
time
timestamp("1 Jan 2021")
startTime
End Time
time
timestamp("1 Jan 2022")
endTime
Deal Start Condition
string
ASAP
dealStartType
Deal Start Source
source
close
sourceDealStart
Show all 13 settings
Setting
Type
Default
Variable
Deal Start Value
float
0
sourceDealStartValue
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.
Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit
Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish
The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window. When price breaks out of the static channel for a confirmed number of
The STRG One Bar Pursuit strategy identifies single-bar momentum reversals by monitoring shifts between bullish and bearish candlesticks starting from the year 2024. It enters a long position when a bullish candle follows a bearish candle and enters a short po
This strategy draws on the price chart and combines Stochastic RSI, the Money Flow Index, and an exponential moving average to open long or short trades. Longs use the lower oscillator thresholds and shorts use the upper ones, with direction limited to longs,
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