OPEN-SOURCE SCRIPT

Price Projection by Linear Regression

Purpose:

This is a TradingView Pine Script indicator that performs a linear regression on historical price data to project potential future price levels. It's designed to help traders visualize long-term price trends and potential future price targets.
Key Components:

User Inputs:

Historical Data Points (default 1000 bars) - The amount of historical data used to calculate the trend
Years to Project (default 10 years) - How far into the future to project the price


Technical Implementation:


Uses linear regression (ta.linreg) to calculate the trend slope
Converts years to trading days using 252 trading days per year
Limits visible projection to 500 bars due to TradingView's drawing limitations
Projects prices using the formula: current_price + (slope × number_of_bars)


Visual Elements:


Blue line showing actual historical prices
Red projection line showing the expected price path
Label showing the projected price at the visible end of the line
Information table in the top-right corner showing:

Current price
Final projected price after the full time period



Limitations:

Can only display projections up to 500 bars into the future (about 2 years) due to TradingView limitations
The full projection value is still calculated and shown in the table
Past performance doesn't guarantee future results - this is a mathematical projection based on historical trends

Usage:
Traders can use this to:

Visualize potential long-term price trends
Set long-term price targets
Understand the historical trend's trajectory
Compare current prices with projected future values

forecastingregressionsTrend Analysis

開源腳本

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

想在圖表上使用此腳本?

免責聲明