Indicator · Pine Script v6 · Own pane

Acceleration (Slope of Slope) (ACCEL)

by mihakralj

This indicator calculates the acceleration of price action by computing the slope of the linear regression slope over a rolling window.

View on GitHub

GitHub stars47on the repository
Pine versionv6current
Lines of code83
Settings2inputs
LicenceMIT
Last update8 months ago28 Feb 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

83 lines of Pine Script v6 from indicators/numerics/accel.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

accel.pine
// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Acceleration (Slope of Slope) (ACCEL)", "ACCEL", overlay=false, precision=8)

//@function Calculates acceleration (slope of slope)
//@param src Source series to calculate slope from
//@param len Lookback period for calculation
//@returns acceleration
accel(series float src, simple int len1) =>
    if len1 <= 1
        runtime.error("Length 1 for slope calculation must be greater than 1")
    var float sumX1 = 0.0, var float sumY1 = 0.0, var float sumXY1 = 0.0, var float sumX21 = 0.0
    var int   validCount1 = 0
    var array<float> x_values1 = array.new_float(len1)
    var array<float> y_values1 = array.new_float(len1)
    var int   head1 = 0
    var int internal_time_counter1 = 0
    if internal_time_counter1 >= len1
        float oldX1 = array.get(x_values1, head1)
        float oldY1 = array.get(y_values1, head1)
        if not na(oldY1)
            sumX1 := sumX1 - oldX1, sumY1 := sumY1 - oldY1
            sumXY1 := sumXY1 - oldX1 * oldY1, sumX21 := sumX21 - oldX1 * oldX1
            validCount1 := validCount1 - 1
    float currentX1 = internal_time_counter1
    float currentY1 = src
    array.set(x_values1, head1, currentX1)
    array.set(y_values1, head1, currentY1)
    if not na(currentY1)
        sumX1 := sumX1 + currentX1, sumY1 := sumY1 + currentY1
        sumXY1 := sumXY1 + currentX1 * currentY1, sumX21 := sumX21 + currentX1 * currentX1
        validCount1 := validCount1 + 1
    head1 := (head1 + 1) % len1
    internal_time_counter1 := internal_time_counter1 + 1
    float current_slope = na
    if validCount1 >= 2
        float n1 = validCount1
        float divisor1 = n1 * sumX21 - sumX1 * sumX1
        if divisor1 != 0.0
            current_slope := (n1 * sumXY1 - sumX1 * sumY1) / divisor1
    var float sumX2 = 0.0, var float sumY2 = 0.0, var float sumXY2 = 0.0, var float sumX22 = 0.0
    var int   validCount2 = 0
    var array<float> x_values2 = array.new_float(len1)
    var array<float> y_values2 = array.new_float(len1)
    var int   head2 = 0
    var int internal_time_counter2 = 0
    if internal_time_counter2 >= len1
        float oldX2 = array.get(x_values2, head2)
        float oldY2 = array.get(y_values2, head2)
        if not na(oldY2)
            sumX2 := sumX2 - oldX2, sumY2 := sumY2 - oldY2
            sumXY2 := sumXY2 - oldX2 * oldY2, sumX22 := sumX22 - oldX2 * oldX2
            validCount2 := validCount2 - 1
    float currentX2 = internal_time_counter2
    float currentY2 = current_slope
    array.set(x_values2, head2, currentX2)
    array.set(y_values2, head2, currentY2)
    if not na(currentY2)
        sumX2 := sumX2 + currentX2, sumY2 := sumY2 + currentY2
        sumXY2 := sumXY2 + currentX2 * currentY2, sumX22 := sumX22 + currentX2 * currentX2
        validCount2 := validCount2 + 1
    head2 := (head2 + 1) % len1
    internal_time_counter2 := internal_time_counter2 + 1
    float calculatedAccel = na
    if validCount2 >= 2
        float n2 = validCount2
        float divisor2 = n2 * sumX22 - sumX2 * sumX2
        if divisor2 != 0.0
            calculatedAccel := (n2 * sumXY2 - sumX2 * sumY2) / divisor2
    calculatedAccel

// ---------- Main loop ----------

// Inputs
i_period = input.int(14, "Period", minval=2)
i_source = input.source(close, "Source")

// Calculation
a = accel(i_source, i_period)

// Plot
plot(a, "Accel", color=color.yellow, linewidth=2)

Overview

Acceleration (Slope of Slope) (ACCEL) utilizes two sequential rolling linear regression stages implemented with circular buffers to ensure deterministic computation. The indicator outputs a single continuous line in a separate chart pane, representing the second derivative of price movement. Users can configure the lookback period and the input source series. It contains no predefined trading signals, threshold bands, or trade execution rules.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescriptpinescript-indicatorstechnical-analysistradingview-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Periodint14i_period
Sourcesourceclosei_source
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers