ThiagoSchmitz

Period Dollar Cost Average Backtester

Here is a simple script to calculate the profits and other dollar cost average strategy statistics. This strategy was created to avoid asset price volatility, so the pump and dump scheme does not affect the portfolio. By dividing the investment amount into periods, the investor doesn’t need to analyze the market, fundamental analysis, or anything. The goal is to increase the asset holdings and avoid fast and robust price movements.

This indicator has some configurations.
  • Amount to buy: the amount to buy at each time
  • Broker fee %: the fee percentage that the broker has for spot trade
  • Frequency: the frequency of the investments. Example: 1 Day means that every day, it will buy an amount of the asset
  • Starting Date: when the indicator will start the investment simulation
  • Ending Date: when the indicator will end the investment simulation
  • InfoCell With/Height: it relates to the panel for view purposes. Change the values to fit better on your screen.

This indicator has three lines:
  • Total Invested (green): total amount invested at the end of the period
  • Total Net Profit (pink): total profit by converting the amount of the asset bought at the latest closing price
  • Holding Profits (yellow): the amount that would be in the portfolio if the investor had invested all the capital in a signal trade at the beginning of the period.

The statistics panel has some information to help you understand buying the asset in one or more trades. So, besides those three lines that were mentioned above, here are the other statistics:
  • Entry Price: The price of the asset when the first investment was made
  • Gross Profit: Total amount of profit, not excluding the losses
  • Gross Losses: Total amount of losses, not excluding the profits
  • Profit Factor: The Gross Profit divided by the Gross Loss. A value above 1 means it’s profitable.
  • Profit/Trades: Net profit per trade. This includes the broker fees.
  • Recovery Factor: The Net profit divided by the relative drawdown. The higher the recovery factor, the faster the recovery of a loss
  • Total Asset Bought: The amount of the asset that was bought at the end of the investment plan
  • Absolute Drawdown: The total amount of losses that made the account balance go below its initial value
  • Relative Drawdown: The max drawdown that occurred, no matter the account balance amount
  • Total Trades: number of times the investment was made in the selected period
  • Total Fee: total Fee that was spent on the total investment
  • Total Winning Trades: the total amount of winning trades. A trade is considered a winner if the net profit is up compared with the latest investment.
  • Total Losing Trades: the total amount of losing trades. A trade is considered a loser if the net profit is down compared to the latest investment.
  • Max consecutive wins: the max amount of consecutive winning trades
  • Max consecutive losses: the max amount of consecutive losing trades

    The chart above uses the default configuration of the indicator. Placed on the BTCUSD market, taking the time range of January 1st, 2018 to January 1st, 2022, 4 years. Buying a BTC amount with 10 USDT every day in that period would generate a more than 500% profit. Compared to the profit amount by just holding the count, which was close to 350% profit, the dollar cost average by period would be much more profitable.

Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?