OPEN-SOURCE SCRIPT
已更新

LinReg SlopeChange

612
This indicator is a precise trend-following tool that tracks the acceleration (rate of change) in the price's linear regression curve. While a standard Linear Regression (LR) indicator simply shows the direction of the price, this tool focuses on detecting whether a trend is gaining momentum or exhausting by measuring the Slope Delta.

Here is a detailed guide explaining the technical structure, parameters, and usage of the indicator:

1. Core Calculation Logic
-The indicator processes market movements through a three-stage mathematical filter:

-Linear Regression (LR): It calculates the "best-fit" line for prices over a specified period (len).

-Slope Percentage (Slope %): It calculates the difference between the current LR value and the previous bar's LR value, expressed as a percentage of the current value.

-Slope Change (Slope Delta): This is the heart of the indicator. It calculates the difference between the current slope percentage and the previous bar's slope percentage. Mathematically, this acts as the "acceleration" (second derivative) of the price action.

2. Input Parameters
-LR Length : The number of lookback bars used for the regression calculation. Higher values lag more but provide more reliable signals.

-Slope Change Threshold (%) : The minimum slope change required to trigger a signal. This can be increased to avoid false signals in noisy (sideways) markets.

-Source : The price data used for calculations (Usually set to close).

3. Signals and Visualization
The indicator operates on a sequential signal logic, meaning it does not produce consecutive "BUY" or "SELL" signals; it waits for a trend reversal.

BUY Signal: Occurs when the momentum of the slope (Slope Delta) breaks above your defined threshold_chg. It is marked by a green triangle on the chart.

SELL Signal: Occurs when the slope momentum breaks below the negative threshold. It is marked by a red inverted triangle.

Background Color: Highlights the active trend by shading the "BUY" zone green and the "SELL" zone red.

4. Usage Strategies

A. Catching Trend Reversals
Because this indicator notices weakening in the slope before the price fully turns, it can respond faster than classic Moving Averages (MA). If the slope begins to decrease (negative delta) during an uptrend, it may serve as a leading signal of a potential peak.

B. Consolidations and Breakouts
When the price is moving sideways, the slope is near zero. Thanks to the Slope Change Threshold parameter, the indicator captures the surge in momentum when price breaks out of stagnation, confirming the start of a new trend.

C. Filtering
Using this indicator in conjunction with a volume indicator (e.g., RV) or an oscillator (like RSI) will increase the success rate. It is particularly powerful for determining trend direction on higher timeframes (4H, Daily).

Note: The threshold_chg (Threshold) parameter should be adjusted according to the volatility of the pair you are trading. For volatile assets like cryptocurrencies, keeping this value slightly higher will reduce "whipsaw" or false signals.
發行說明
timeframe
發行說明
sign
發行說明
I changed the calculation method. Now, instead of using average value of slope delta, indicator uses average of previous slope values.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。