OPEN-SOURCE SCRIPT
Telah dikemas kini

Returns & Distance from ATH

174
Here’s what that Pine Script does, in everyday terms:

1. **Look back in time**
- It grabs the closing price from **3 months ago** and **1 month ago** by asking TradingView’s “monthly” data for the symbol.

2. **Calculate percentage changes**
- **3-month return** = (today’s close – close 3 months ago) ÷ (close 3 months ago) × 100
- **1-month return** = (today’s close – close 1 month ago) ÷ (close 1 month ago) × 100

3. **Track the highest price ever seen (ATH)**
- It keeps a running “all-time high” variable, updating it any time today’s high exceeds the previous ATH.

4. **Compute how far you are below ATH**
- **% from ATH** = (ATH – today’s close) ÷ ATH × 100

5. **Build a little stats table on your chart**
- It makes a 2-row by 3-column box in the **top-center** of your price panel.
- The **first row** has labels: “3M % Return”, “1M % Return”, “% from ATH”.
- The **second row** shows the three computed numbers, each formatted to two decimal places and suffixed with “%.”

6. **Refresh only once per bar**
- All of these values and the table get updated **at the close** of each bar, so your table always shows the latest stats without cluttering the chart with extra drawings.

In short, this indicator quietly collects the right historical prices, does three simple percent-change math steps, and then displays those three key numbers in a neat, always-visible box at the top of your TradingView chart.
Nota Keluaran
Here’s what that Pine Script does, in everyday terms:

1. **Look back in time**
- It grabs the closing price from **3 months ago** and **1 month ago** by asking TradingView’s “monthly” data for the symbol.

2. **Calculate percentage changes**
- **3-month return** = (today’s close – close 3 months ago) ÷ (close 3 months ago) × 100
- **1-month return** = (today’s close – close 1 month ago) ÷ (close 1 month ago) × 100

3. **Track the highest price ever seen (ATH)**
- It keeps a running “all-time high” variable, updating it any time today’s high exceeds the previous ATH.

4. **Compute how far you are below ATH**
- **% from ATH** = (ATH – today’s close) ÷ ATH × 100

5. **Build a little stats table on your chart**
- It makes a 2-row by 3-column box in the **top-center** of your price panel.
- The **first row** has labels: “3M % Return”, “1M % Return”, “% from ATH”.
- The **second row** shows the three computed numbers, each formatted to two decimal places and suffixed with “%.”

6. **Refresh only once per bar**
- All of these values and the table get updated **at the close** of each bar, so your table always shows the latest stats without cluttering the chart with extra drawings.

In short, this indicator quietly collects the right historical prices, does three simple percent-change math steps, and then displays those three key numbers in a neat, always-visible box at the top of your TradingView chart.

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.