Ehlers Undersampled Double Moving Average Indicator [CC]
"Ehlers Undersampled Double Moving Average Indicator [CC]" by cheatcountry, MIT. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Ehlers Undersampled Double Moving Average Indicator [CC] (v1.0), read 2026-10-12T15:42:55.750Z; source language v5.
Licence: MIT License (MIT) — full text.
Ehlers Undersampled Double Moving Average Indicator [CC] by cheatcountry, ported from Pine v5. Overlay indicator with 2 plots, alerts and 7 inputs.
// Copyright (c) 2019-present, Franklin Moormann (cheatcountry)
// Ehlers Undersampled Double Moving Average Indicator [CC] script may be freely distributed under the MIT license.
// ------------------------------------------------------------------------------------------------
// Original author: cheatcountry
// Original title: Ehlers Undersampled Double Moving Average Indicator [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 Undersampled Double Moving Average Indicator [CC]", overlay=true)
float inp = input.source(title="Source", defval=hlcc4)
string res = input.timeframe(title="Resolution", defval="")
bool rep = input.bool(title="Allow Repainting?", defval=false)
bool bar = input.bool(title="Allow Bar Color Change?", defval=false)
float src = inp[rep ? 0 : barstate.isrealtime ? 1 : 0][rep ? 0 : barstate.isrealtime ? 0 : 1]
int fastLength = input.int(title='FastLength', defval=6, minval=1)
int slowLength = input.int(title='SlowLength', defval=12, minval=1)
int sampleLength = input.int(title='SampleLength', defval=5, minval=1)
hannFilter(float sampleSrc, int length) =>
filt = 0.0
coef = 0.0
for i = 1 to length
cosine = 1 - math.cos(2 * math.pi * i / (length + 1))
filt := filt + cosine * nz(sampleSrc[i - 1])
coef := coef + cosine
filt := coef != 0 ? filt / coef : 0
float sample = 0.0
sample := bar_index % sampleLength == 0 ? src : nz(sample[1])
float fastAvg = hannFilter(sample, fastLength)
float slowAvg = hannFilter(sample, slowLength)
float slo = fastAvg - slowAvg
int 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")
alertcondition(ta.crossover(sig, 0) or ta.crossover(sig, 1), "All Buy Signals", "Any Bullish Change Detected")
alertcondition(ta.crossunder(sig, 0) or ta.crossunder(sig, -1), "All Sell Signals", "Any Bearish Change Detected")
color udsmaColor = sig > 1 ? color.green : sig > 0 ? color.lime : sig < -1 ? color.maroon : sig < 0 ? color.red : color.black
barcolor(bar ? udsmaColor : na)
plot(fastAvg, title="FastAverage", color=udsmaColor, linewidth=2)
plot(slowAvg, title="SlowAverage", color=chart.fg_color, linewidth=1)
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.