OPEN-SOURCE SCRIPT

DCA Valuation & Unrealized Gains

This Pine Script for TradingView calculates and visualizes the relationship between a Dollar Cost Average (DCA) price and the All-Time High (ATH) price for over 50 different cryptocurrencies. Here's what it does:

1. Inputs for DCA Prices:
- Users can manually input DCA prices for specific cryptocurrencies (e.g., BTC, ETH, BNB).

2. Dynamic ATH Calculation:
- Dynamically calculates the ATH price for the current asset using the highest price in the chart's loaded data and persists this value across bars.

3. Percentage Change from DCA to ATH:
- Computes the percentage gain from the DCA price to the ATH price.

4. Visualizations:
- Draws a line at the DCA price and the ATH price, both extended to the right.
- Adds an arrow pointing from the DCA price to the ATH, offset by 10 bars into the future.
- Displays labels for:
- The percentage gain from DCA to ATH.
- "No DCA Configured" if no valid DCA price is set for the asset.

5. Color Coding:
- Labels and arrows are color-coded to indicate positive or negative percentage changes:
- Green for gains.
- Red for losses.

6. Adaptability:
- The script dynamically adjusts to the current asset based on its ticker and uses the corresponding DCA price.

This functionality provides traders with clear insights into their investment's performance relative to its ATH, aiding in decision-making.
-----
To add a new asset to the script:

1. Define the DCA Input: Add a new input for the asset's DCA price using the `input.float` function. For example:



2. Add the Asset Logic: Include a conditional check for the new asset in the ticker matching logic:



Where NEW is the ticker symbol of the asset you're adding.

NOTE: SOLO had to be put before SOL because otherwise the indicator was pulling the DCA price from SOL even on the SOLO chart. If you have a similar issue, try that fix.

Adding an asset requires only these two changes. Once done, the script dynamically incorporates the new asset into its calculations and visualizations.
alltimehighcryptomarketDCAeducationalportfolioPortfolio management

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明