DCA Simulator [QuantAlgo]

2 813

More exclusive indicators from QuantAlgo

Subscribe to QuantAlgo Essential for $49.99/month to get exclusive indicators by this author. You pay right on TradingView and can use them on your charts straight away.

Explore QuantAlgo Essential
🟢 Overview

The DCA Simulator is a comprehensive dollar-cost averaging tool built for investors who want to see how a recurring buy strategy would have performed on any chart. It places scheduled buys at a chosen frequency and point in each period, can scale each buy by how far price sits from its long-term average, and applies configurable fees and slippage to every fill. A dashboard then tracks the average cost, return, and max drawdown of the DCA strategy and compares it with a single lump sum and a fixed amount DCA on the same schedule. Whether you accumulate crypto around the clock or build equity positions on a weekday schedule, the indicator turns a recurring plan into measurable results directly on the chart.
快照
🟢 What is Dollar-Cost Averaging?

Dollar-cost averaging (DCA) invests a set amount at regular intervals regardless of price. Because the amount stays constant, each buy collects more units when price is low and fewer when it is high, so the average cost per unit lands at or below the simple average of the buy prices. Spreading entries across time also removes the need to pick a single entry point, which makes DCA a widely used way to build long-term positions. A valuation-weighted variant keeps the fixed schedule but buys more when price sits well below its long-term average and less when it is stretched above it, tilting capital toward periods when price is cheap relative to its own history. How either approach compares with investing everything at once depends on the path price takes, which is why the simulator measures all of them side by side.
快照
🟢 Key Features

▶ Flexible Buy Schedule

Frequency sets how often the DCA strategy buys:

1. Daily buys once a day.

2. Weekly buys once a week.

3. Bi-Weekly buys once every two weeks.

4. Monthly buys once a month.

5. Quarterly buys once every three months.

Each of these spans is one period, and two schedule anchors decide how the periods line up.

Calendar keeps every buy on calendar weeks and months, starting with the first period that begins on or after the start date. Bi-Weekly and Quarterly count from that first week or month, so Quarterly lines up with calendar quarters when that first month is January, April, July, or October.

Start Date counts every period from the first bar on or after the chosen date, so buys repeat on that day, such as every Wednesday or the 15th of every month. This works the same way a recurring buy repeats from the day it is set up. When that day is the 29th, 30th, or 31st, shorter months use their last day. A scheduled day without a bar, such as a weekend or holiday on markets that close, moves to the next available bar.

Buy Timing places every buy at the start or the end of its period. Start of Period fills at the open of the period's first bar, the moment the period begins. End of Period fills at the close of the period's last bar and records the buy as the next period opens, since a bar is only known to be the last of its period once the next one starts. On markets that trade around the clock, one period's close and the next period's open are nearly the same price, so the two timings differ mainly by a one-period shift. Markets with overnight or weekend gaps separate them.
快照
▶ Valuation Weighting

Mode chooses between two ways of sizing each buy. Fixed Amount invests the same base amount every time. Valuation Weighted scales each buy by how stretched price is compared with its own history.

To do this, Valuation Weighted measures the log distance between price and its moving average and divides it by the root mean square of that distance over the same window to form a z-score. It then multiplies the base amount by one minus Weight Sensitivity times that z-score, held between Min Weight and Max Weight. Buys at the start of a period read the valuation at the prior close, and buys at the end read it at their own close, so every buy is sized only with information available at that moment.

1. Valuation Length: Sets the window behind both the moving average and the typical distance from it. Shorter lengths judge value against the recent trend, while longer lengths judge it against a broader cycle.

2. Weight Sensitivity: Controls how strongly the z-score moves each buy. A buy placed exactly at the average uses the base amount, and higher values reach the minimum and maximum weights more often.

3. Min Weight: Sets the smallest multiple of the base amount. At zero, buys are skipped entirely once price is stretched far enough above its average, while the fixed amount benchmark keeps buying on those dates.

4. Max Weight: Caps how large a single buy can grow during deep discounts, keeping the capital committed to any one buy within a set limit.
快照
▶ Performance Dashboard

The dashboard summarizes the DCA strategy in a single table that can be placed in any of nine chart positions.

1. Start Date: The first chart bar on or after the start date setting.

2. Buys: The number of executed buys, excluding any skipped by valuation.

3. Total Invested: All cash put in, fees included.

4. Units Held: The quantity accumulated so far.

5. Average Cost: The average price paid per unit, with every cost included.

6. Current Value: The holdings marked at the latest price.

7. Return: The gain or loss on the total invested.

8. Max Drawdown: The deepest decline the DCA strategy has held through.

9. Lump Sum Return: The result of investing the same total all at once at the first buy's price.

10. Fixed DCA Return: The result of buying the base amount on every scheduled date, the benchmark for Valuation Weighted mode.

11. Next Weight: The weight and z-score a buy would use at the latest close.

Units are fractional, and current value is marked before any selling fee.
快照
▶ Max Drawdown Tracking

Max Drawdown records the deepest point the DCA strategy has held through since its first buy, with three controls that define how it is measured.

1. Drawdown Basis: Below Cost measures the fall of the holdings below the total invested. From Peak measures the fall from the highest value reached, with every later buy added to that peak, so gains given back also count.

2. Drawdown Data: Confirmed counts completed bars only, while Live also updates the figure on the forming bar as price develops.

3. Count Wicks: Adds each bar's open, low, and high to its close and values every price against the position held at that moment. A bar's high is never paired with its own low, since their order inside the bar is unknown.
快照
▶ Fees and Slippage

Two fee modes cover the common ways a purchase is billed:

1. Deducted From Order takes the fee out of the buy, so each buy costs exactly its amount and receives fewer units. This works out the same whether the fee comes from the amount spent or from the coins received.

2. Added On Top puts the full amount into the order and charges the fee separately, as when it is paid with a fee token or billed on top in the quote currency.

Slippage raises every fill price by a set percentage to account for the spread and movement during execution. Both costs flow through the average cost and returns. The lump sum and fixed amount comparisons pay the same fee and slippage, so every figure is measured on equal terms.
快照
▶ Average Cost Line and Buy Markers

A step line traces the running average cost, with a label at the latest bar, and each can be shown on its own. Price above the line means the DCA strategy is in profit, and price below it means the DCA strategy sits below its cost basis. Triangle markers print below every executed buy. In Valuation Weighted mode each marker is shaded by the weight of its buy, so heavier buying during discounts stands out at a glance, and skipped buys print no marker.
快照
▶ Built-in Alerts

Six ready-made alert conditions cover every key event in the DCA strategy, and buy alerts can fire as soon as each buy is recorded.

1. Scheduled Buy: Fires on every executed buy.

2. Increased Buy: Fires when a buy uses more than the base amount in Valuation Weighted mode.

3. Reduced Buy: Fires when a buy uses less than the base amount in Valuation Weighted mode.

4. Skipped Buy: Fires when a scheduled buy is skipped because its valuation weight reached zero.

5. Return Turned Positive: Fires when price closes above the average cost and the return turns positive.

6. Return Turned Negative: Fires when price closes below the average cost and the return turns negative.

The Any alert() function call option also delivers a detailed message with the symbol, amount, price, and weight of each executed buy, along with the z-score of each skipped one.
快照
▶ Visual Customization

Six color presets (Classic, Aqua, Cosmic, Cyber, Neon, Custom) set the buy marker and negative return colors across the chart and dashboard, and Custom mode exposes individual color pickers. The average cost line, its label, and its dashboard figure keep their own color under every preset so the cost basis stays easy to spot. The label text switches between dark and light automatically to stay readable on any chosen color. Text size is adjustable from Tiny to Large for both the average cost label and the dashboard, suiting anything from a compact chart layout to presentations and screen recordings.
快照
▶ Timeframe Warning

With the Calendar anchor, each frequency is designed for these chart timeframes:

1. Daily: one day or lower.

2. Weekly and Bi-Weekly: one week or lower.

3. Monthly and Quarterly: one month or lower.

This lets long histories run on weekly and monthly charts. With the Start Date anchor, every frequency is designed for chart timeframes of one day or lower, since its scheduled days fall inside weekly and monthly bars. When the chart timeframe is higher, a warning box in the center of the chart shows the timeframe the chosen settings are designed for, so the simulation always runs on bars that match its schedule. All prices come from the chart's own bars, so the simulation is designed for standard bar and candle charts.
快照

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。