OPEN-SOURCE SCRIPT

Linear Regression Trendline on Close

686

This indicator draws a linear regression trendline that connects the closing prices of the last N candles, where N is a user-defined input.

🔹 Key Features:

Uses least-squares linear regression to fit a straight line to recent closes

Automatically adapts to any timeframe (5min, 1h, daily, etc.)

Input lets you select how many recent candles to include

Helps identify short-term trend direction and momentum

🔸 How to Use:

Set the "Number of Candles" input to choose how far back the regression line should look

The line updates in real time as new candles form

Use it to gauge short-term bias, or combine with support/resistance/zones for confirmation

🧠 Tip: Increase the number of candles for smoother trends; decrease for more reactive trendlines.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.