Untitled
"TASC 2023.04 Undersampled Double MA" by PineCodersTASC, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TASC 2023.04 Undersampled Double MA (v1.0), read 2026-11-15T18:32:42.531Z; source language v5.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
TASC 2023.04 Undersampled Double MA by PineCodersTASC, ported from Pine v5. Overlay indicator with 2 plots and 3 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2023-03-14; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// TASC Issue: April 2023 - Vol. 41, Issue 5
// Article: Undersampling The Data As A Smoothing Technique.
// Just Ignore Them.
// Article By: John Ehlers
// Language: Pine-compatible v5
// Provided By: PineCoders, for tradingview.com
// ------------------------------------------------------------------------------------------------
// Original author: PineCodersTASC
// Original title: TASC 2023.04 Undersampled Double MA
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 5
// Fetched: 2026-11-15
// 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
string title = 'TASC 2023.04 Undersampled Double MA'
string stitle = 'UDMA'
indicator(title, stitle, true)
// @function Samples a source every period of bars.
// @param period int . Period of sampling.
// @param source float . Data source.
// @returns float.
sampledSource(int period = 5, float source = close) =>
var float sample = source
// sample every period:
if bar_index % period == 0
sample := source
sample
// @function Hann Windowed Lowpass FIR Filter.
// @param source float . Data source.
// @param length int . Length period.
// @returns float.
hann(float source, int length) =>
float PIx2 = math.pi * 2.0
filt = 0.0
coef = 0.0
for count = 1 to length
float w = 1.0 - math.cos(PIx2 * count / (length + 1.0))
filt += w * nz(source[count - 1])
coef += w
float hann = coef != 0.0 ? filt / coef : na
hann
// @function Undersampled Double Moving Average.
// @param length int . Length period.
// @param samplePeriod int . Sampling period.
// @param source float . Data source.
// @returns float.
udma(int length = 6, int samplePeriod = 5, float source = close) =>
float sample = sampledSource(samplePeriod, source)
//find average using Hann FIR filter:
float result = hann(sample, length)
result
int samplePeriod = input.int(5, 'Sampling period:', 1)
int fastLength = input.int(6, 'Fast period:', 1)
int slowLength = input.int(12, 'Slow period:', 1)
float fast = udma(fastLength, samplePeriod)
float slow = udma(slowLength, samplePeriod)
plot(fast, 'Fast UDMA', color.red, 4)
plot(slow, 'Slow UDMA', color.navy, 4)
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCodersTASC, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
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.