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 אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור