OPEN-SOURCE SCRIPT
更新済 LinReg SlopeChange

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.
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の精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。