mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 09:47:43 +00:00
24e86d762a
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
32 lines
1017 B
Plaintext
32 lines
1017 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Median Absolute Error", "MdAE", overlay=false)
|
|
|
|
//@function Calculates Median Absolute Error
|
|
//@param actual Series of actual values
|
|
//@param predicted Series of predicted/forecast values
|
|
//@param length Rolling window for median calculation
|
|
//@returns MdAE value
|
|
mdae(series float actual, series float predicted, simple int length) =>
|
|
// Compute absolute error for current bar
|
|
float absError = math.abs(nz(actual, 0.0) - nz(predicted, 0.0))
|
|
|
|
// Use ta.median for rolling median of absolute errors
|
|
float result = ta.median(absError, length)
|
|
result
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_length = input.int(14, "Length", minval=1)
|
|
i_actual = input.source(close, "Actual")
|
|
i_predicted = input.source(open, "Predicted")
|
|
|
|
// Calculation
|
|
mdae_value = mdae(i_actual, i_predicted, i_length)
|
|
|
|
// Plot
|
|
plot(mdae_value, "MdAE", color=color.yellow, linewidth=2)
|
|
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
|