Computing FIR Filters Using Arrays [WMA Example]
"Computing FIR Filters Using Arrays [WMA Example]" by PineCoders, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Computing FIR Filters Using Arrays [WMA Example] (v1.0), read 2026-10-12T16:12:12.507Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Computing FIR Filters Using Arrays [WMA Example] by PineCoders, ported from Pine v4. Overlay indicator with 1 plot and 2 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// REUSING THIS CODE: You are welcome to reuse this code without permission. Credits are appreciated.
//@author=alexgrover,️ for PineCoders
// Computing FIR Filters Using Arrays [WMA Example]
// This script provides a template for calculating FIR filters using arrays.
// The calculation of the coefficients should be executed in line 18 (variable `w`).
// PineCoders, Tools and ideas for all Pine coders: pinecoders.com
// ------------------------------------------------------------------------------------------------
// Original author: PineCoders
// Original title: Computing FIR Filters Using Arrays [WMA Example]
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// 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
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Computing FIR Filters Using Arrays [WMA Example]", overlay=true)
length = input(14)
src = input(close)
//----
var b = array.new_float(0)
if barstate.isfirst
for i = 0 to length - 1
w = length - i
array.push(b, w)
den = array.sum(b)
//----
sum = 0.
for i = 0 to length - 1
sum := sum + src[i] * array.get(b, i)
filt = sum / den
//----
plot(filt, "Plot", #2157f3, 2)
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCoders, 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.