mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-31 02:47:44 +00:00
35a6702b06
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.
30 lines
822 B
Plaintext
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)
|