Indicator · Pine Script v6 · Own pane

Acceleration, Slope of Slope (JERK)

by mihakralj

This indicator plots jerk, described as the slope of the slope of the slope of a source series, in a separate pane.

View on GitHub

GitHub stars47on the repository
Pine versionv6current
Lines of code112
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

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

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

//@function Calculates jerk (slope of slope of slope)
//@param src Source series to calculate slope from
//@param len Lookback period for calculation
//@returns jerk
jerk(series float src, simple int len1) =>
    if len1 <= 1
        runtime.error("Length 1 for first 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_slope1 = na
    if validCount1 >= 2
        float n1 = validCount1
        float divisor1 = n1 * sumX21 - sumX1 * sumX1
        if divisor1 != 0.0
            current_slope1 := (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_slope1
    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 current_accel = na
    if validCount2 >= 2
        float n2 = validCount2
        float divisor2 = n2 * sumX22 - sumX2 * sumX2
        if divisor2 != 0.0
            current_accel := (n2 * sumXY2 - sumX2 * sumY2) / divisor2
    var float sumX3 = 0.0, var float sumY3 = 0.0, var float sumXY3 = 0.0, var float sumX23 = 0.0
    var int   validCount3 = 0
    var array<float> x_values3 = array.new_float(len1)
    var array<float> y_values3 = array.new_float(len1)
    var int   head3 = 0
    var int internal_time_counter3 = 0
    if internal_time_counter3 >= len1
        float oldX3 = array.get(x_values3, head3)
        float oldY3 = array.get(y_values3, head3)
        if not na(oldY3)
            sumX3 := sumX3 - oldX3, sumY3 := sumY3 - oldY3
            sumXY3 := sumXY3 - oldX3 * oldY3, sumX23 := sumX23 - oldX3 * oldX3
            validCount3 := validCount3 - 1
    float currentX3 = internal_time_counter3
    float currentY3 = current_accel
    array.set(x_values3, head3, currentX3)
    array.set(y_values3, head3, currentY3)
    if not na(currentY3)
        sumX3 := sumX3 + currentX3, sumY3 := sumY3 + currentY3
        sumXY3 := sumXY3 + currentX3 * currentY3, sumX23 := sumX23 + currentX3 * currentX3
        validCount3 := validCount3 + 1
    head3 := (head3 + 1) % len1
    internal_time_counter3 := internal_time_counter3 + 1
    float calculatedjerk = na
    if validCount3 >= 2
        float n3 = validCount3
        float divisor3 = n3 * sumX23 - sumX3 * sumX3
        if divisor3 != 0.0
            calculatedjerk := (n3 * sumXY3 - sumX3 * sumY3) / divisor3
    calculatedjerk

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

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

// Calculation
a = jerk(i_source, i_period)

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

Overview

Acceleration, Slope of Slope (JERK) estimates each slope with a rolling least-squares fit over the selected period, then repeats that fit on the slope and again on the resulting acceleration. The period and source inputs set the lookback and the price series. Values stay unavailable until enough valid samples exist, and the function rejects a length of one or less. It does not generate trade signals.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum

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

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator

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
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

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