mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-30 18:47:42 +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.
27 lines
716 B
Plaintext
27 lines
716 B
Plaintext
// Licensed under the Apache License, Version 2.0
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("First Derivative / Velocity (SLOPE)", "SLOPE", overlay=false, precision=8)
|
|
|
|
//@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
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
|
|
// Calculation
|
|
s = slope(i_source)
|
|
|
|
// Plot
|
|
plot(s, "Slope", color=color.yellow, linewidth=2)
|