Skip to content
All library documents

RSI-Triggered DCA Backtesting with Scaled Safety Orders and Fixed Targets

Article TradingView scripts

Summary

This script models long or short dollar-cost averaging strategies using RSI threshold crossings to start a deal. It places an initial limit order and up to ten safety orders at progressively wider price deviations. Safety-order size is controlled by a multiplier and increases across the sequence. Users can select a backtest date range, configure a percentage take-profit target, and optionally enable a stop based on the furthest planned averaging level. Long and short modes are mutually exclusive.

The code closes the basket when price crosses the configured profit or stop threshold and cancels remaining entry orders. It also sets commission and slippage assumptions, which affect reported backtest performance. The stop is measured from the furthest planned DCA level rather than the average fill price, while the profit target is calculated from the initial order price; these choices may differ from live exchange behavior and exposure after partial fills. The document supplies configurable mechanics but no reported performance results, and DCA can accumulate substantial exposure if price continues moving against the position.

Key ideas

  • An RSI crossing triggers a long or short deal within the selected backtest period.
  • The strategy places an initial limit entry and up to ten additional orders at scaled price deviations.
  • Safety-order sizes increase according to a configurable multiplier, while the target profit is set as a percentage from the initial order price.
  • An optional stop is derived from the furthest planned averaging level rather than the basket's average fill.
  • Commission and slippage are included as simulation assumptions, but the document reports no backtest outcome.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.