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("First Derivative / Velocity (SLOPE)", "SLOPE", 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 first finite difference (velocity): Slope = V[t] - V[t-1]
|
|
|
|
|
//@param src Source series
|
|
|
|
|
//@returns First difference of consecutive values. Returns 0.0 on first bar.
|
|
|
|
|
//@optimized Uses direct history access for zero-allocation streaming.
|
|
|
|
|
slope(series float src) =>
|
|
|
|
|
float prev = src[1]
|
|
|
|
|
if na(prev)
|
|
|
|
|
0.0
|
|
|
|
|
else
|
|
|
|
|
src - prev
|
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
|
|
|
s = slope(i_source)
|
2026-01-18 19:02:03 -08:00
|
|
|
|
|
|
|
|
// Plot
|
|
|
|
|
plot(s, "Slope", color=color.yellow, linewidth=2)
|