Ehlers Median Average Adaptive Filter [CC]
"Ehlers Median Average Adaptive Filter [CC]" by cheatcountry, MIT. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Ehlers Median Average Adaptive Filter [CC] (v1.0), read 2026-10-12T15:45:47.498Z; source language v5.
Licence: MIT License (MIT) — full text.
Ehlers Median Average Adaptive Filter [CC] by cheatcountry, ported from Pine v5. Overlay indicator with 1 plot, alerts and 6 inputs.
// Copyright (c) 2019-present, Franklin Moormann (cheatcountry)
// Ehlers Median Average Adaptive Filter [CC] script may be freely distributed under the MIT license.
// ------------------------------------------------------------------------------------------------
// Original author: cheatcountry
// Original title: Ehlers Median Average Adaptive Filter [CC]
// Licence: MIT (the header above is the original notice, kept verbatim)
// Pine version: 5
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
indicator('Ehlers Median Average Adaptive Filter [CC]', max_bars_back=3000, overlay=true)
inp = input(title='Source', defval=close)
res = input.timeframe(title='Resolution', defval='')
rep = input(title='Allow Repainting?', defval=false)
bar = input(title='Allow Bar Color Change?', defval=false)
src = inp[rep ? 0 : barstate.isrealtime ? 1 : 0][rep ? 0 : barstate.isrealtime ? 0 : 1]
threshold = input.float(title='Threshold', defval=0.002, minval=0.0001, step=0.001)
length = input.int(title='Length', defval=39, minval=1)
smth = (src + 2 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 6
len = length
v3 = 0.2
v2 = 0.0
alpha = 0.0
while v3 > threshold and len > 0
alpha := 2.0 / (len + 1)
v1 = ta.median(smth, len)
v2 := alpha * smth + (1 - alpha) * nz(v2[1])
v3 := v1 != 0 ? math.abs(v1 - v2) / v1 : v3
len -= 2
len := len < 3 ? 3 : len
alpha := 2.0 / (len + 1)
filter = 0.0
filter := alpha * smth + (1 - alpha) * nz(filter[1])
slo = src - filter
sig = slo > 0 ? (slo > nz(slo[1]) ? 2 : 1) : slo < 0 ? (slo < nz(slo[1]) ? -2 : -1) : 0
alertcondition(ta.crossover(sig, 1), 'Strong Buy Signal', 'Strong Bullish Change Detected')
alertcondition(ta.crossunder(sig, -1), 'Strong Sell Signal', 'Strong Bearish Change Detected')
alertcondition(ta.crossover(sig, 0), 'Buy Signal', 'Bullish Change Detected')
alertcondition(ta.crossunder(sig, 0), 'Sell Signal', 'Bearish Change Detected')
maafColor = sig > 1 ? color.green : sig > 0 ? color.lime : sig < -1 ? color.maroon : sig < 0 ? color.red : color.black
barcolor(bar ? maafColor : na)
plot(filter, title='MAAF', linewidth=2, color=maafColor)
This file is under the MIT License; it is a port of the original by cheatcountry, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.