Files
Miha Kralj 35a6702b06 fix(docs): correct .md documentation across errors, dynamics, filters, forecasts, momentum, numerics, oscillators, reversals, statistics, trends, volatility, volume
Deep review of all indicator categories verified .md headers against .cs WarmupPeriod, parameters, inputs, and outputs. Fixes include warmup corrections, parameter documentation, output type accuracy, and Pine Script alignment.
2026-03-10 18:38:23 -07:00

30 lines
822 B
Plaintext

// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Third Derivative / Jerk (JERK)", "JERK", overlay=false, precision=8)
//@function Calculates the third finite difference (jerk): Jerk = V[t] - 3*V[t-1] + 3*V[t-2] - V[t-3]
//@param src Source series
//@returns Third difference. Returns 0.0 until 4 bars are available.
//@optimized Uses direct history access and binomial coefficients [1,-3,3,-1].
jerk(series float src) =>
float v0 = src
float v1 = src[1]
float v2 = src[2]
float v3 = src[3]
if na(v1) or na(v2) or na(v3)
0.0
else
v0 - 3.0 * v1 + 3.0 * v2 - v3
// ---------- Main loop ----------
// Inputs
i_source = input.source(close, "Source")
// Calculation
j = jerk(i_source)
// Plot
plot(j, "Jerk", color=color.yellow, linewidth=2)