Files
Miha Kralj 7ec79538aa refactor: move Decay/Edecay from trends_IIR to numerics; update filter signatures
- Move lib/trends_IIR/decay/ → lib/numerics/decay/
- Move lib/trends_IIR/edecay/ → lib/numerics/edecay/
- Update Category in Decay.md/Edecay.md from Trends (IIR) to Numerics
- Add DECAY/EDECAY entries to lib/numerics/_index.md and docs/indicators.md
- Update filter signature .md files and .svg assets
- Update trends_IIR signature docs (htit, mama, holt, etc.)
- All 163 tests passing, 0 warnings, 0 errors
2026-03-10 20:33:55 -07:00

33 lines
890 B
Plaintext

// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Linear Decay (DECAY)", "DECAY", overlay=true)
//@function Calculates linear decay: output = max(input, prev_output - 1/period)
//@param source Source price series
//@param length Decay period
//@returns Decayed value that tracks peaks and descends linearly
decay(series float source, simple int length) =>
var float prev = na
float scale = 1.0 / length
float result = na
if na(prev)
result := source
else
float d = prev - scale
result := source > d ? source : d
prev := result
result
// ---------- Main loop ----------
// Inputs
i_source = input.source(close, "Source")
i_length = input.int(5, "Length", minval=1)
// Calculate Decay
float decay_val = decay(i_source, i_length)
// Plot
plot(decay_val, "Decay", color=color.yellow, linewidth=2)