feat: add new indicators (Decay, Edecay, MinusDi, MinusDm, PlusDi, PlusDm, Maxindex, Minindex, Sarext) and update pine scripts, core libs, validation tests, and python bindings
2026-03-09 13:45:46 -07:00
|
|
|
// Licensed under the Apache License, Version 2.0
|
2026-01-18 19:02:03 -08:00
|
|
|
// © mihakralj
|
|
|
|
|
//@version=6
|
fix(docs): correct .md documentation across errors, dynamics, filters, forecasts, momentum, numerics, oscillators, reversals, statistics, trends, volatility, volume
2026-03-10 18:38:23 -07:00
|
|
|
indicator("Second Derivative / Acceleration (ACCEL)", "ACCEL", overlay=false, precision=8)
|
2026-01-18 19:02:03 -08:00
|
|
|
|
fix(docs): correct .md documentation across errors, dynamics, filters, forecasts, momentum, numerics, oscillators, reversals, statistics, trends, volatility, volume
2026-03-10 18:38:23 -07:00
|
|
|
//@function Calculates the second finite difference (acceleration): Accel = V[t] - 2*V[t-1] + V[t-2]
|
|
|
|
|
//@param src Source series
|
|
|
|
|
//@returns Second difference. Returns 0.0 until 3 bars are available.
|
|
|
|
|
//@optimized Uses direct history access and FMA-equivalent for zero-allocation streaming.
|
|
|
|
|
accel(series float src) =>
|
|
|
|
|
float v0 = src
|
|
|
|
|
float v1 = src[1]
|
|
|
|
|
float v2 = src[2]
|
|
|
|
|
if na(v1) or na(v2)
|
|
|
|
|
0.0
|
|
|
|
|
else
|
|
|
|
|
v0 - 2.0 * v1 + v2
|
2026-01-18 19:02:03 -08:00
|
|
|
|
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
|
|
|
|
|
|
// Inputs
|
|
|
|
|
i_source = input.source(close, "Source")
|
|
|
|
|
|
|
|
|
|
// Calculation
|
fix(docs): correct .md documentation across errors, dynamics, filters, forecasts, momentum, numerics, oscillators, reversals, statistics, trends, volatility, volume
2026-03-10 18:38:23 -07:00
|
|
|
a = accel(i_source)
|
2026-01-18 19:02:03 -08:00
|
|
|
|
|
|
|
|
// Plot
|
|
|
|
|
plot(a, "Accel", color=color.yellow, linewidth=2)
|