Filter Information Box - PineCoders FAQ
"Filter Information Box - PineCoders FAQ" by PineCoders, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Filter Information Box - PineCoders FAQ (v3.0), read 2026-10-12T16:12:18.822Z; 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.
Filter Information Box - PineCoders FAQ by PineCoders, ported from Pine v4. Overlay indicator with drawings 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, but only if you also publish open-source. Credits are appreciated.
//@author=alexgrover,️ for PineCoders
// Filter Information Box - PineCoders FAQ
// v1, 2020.04.14 18:06
// PineCoders, Tools and ideas for all Pine coders: pinecoders.com
// A script showing the properties such as lag and smoothness of any filter.
// For accurate results make sure the filter weights add up to 1 in case of a low-pass or band-stop filter,
// 0 in the case of a band-pass or high-pass filter. If the filter is recursive, make sure it is stable.
// It is recommended to use non-adaptive filters.
// PineCoders FAQ & Code question linking here : https://www.pinecoders.com/faq_and_code/#how-can-i-evaluate-a-filter-i-am-planning-to-use
// This indicator's TradingView page : https://www.tradingview.com/script/oTEP9DJF-Filter-Information-Box-PineCoders-FAQ/
// ------------------------------------------------------------------------------------------------
// Original author: PineCoders
// Original title: Filter Information Box - PineCoders FAQ
// 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("Filter Information Box - PineCoders FAQ", overlay=true)
//-------------------------------------------------------------------------------------
start = input(1000, "Impulse Position") //Bar number at which the impulse is equal to 1
//-------------------------------------------------------------------------------------
//This section can be used to declare the settings affecting your filter
//-------------------------------------------------------------------------------------
length = input(9)
//-------------------------------------------------------------------------------------
//Function holding your filter. Keep the argument "input" as filter input.
//-------------------------------------------------------------------------------------
f(input) => ta.sma(input, length)
//-------------------------------------------------------------------------------------
//Impulse response, lag and Herfindhal index calculation
//-------------------------------------------------------------------------------------
n = bar_index
i = n == start ? 1 : 0
imp = f(i)
//----
seq = ta.barssince(imp[i] == 0 or ta.crossunder(imp, 0) or ta.crossover(imp, 0))
lag = ta.cum(imp * seq)
hi = ta.cum(imp * imp)
//-------------------------------------------------------------------------------------
//Percentage Overshot/Positive Weights
//-------------------------------------------------------------------------------------
step = f(bar_index > start ? 1 : 0)
max = 0.
max := nz(math.max(step, max[1]))
pw = ta.cum(math.max(math.sign(imp), 0)) / ta.cum(math.abs(math.sign(imp))) * 100
po = (max - 1) * 100
//-------------------------------------------------------------------------------------
//Classification
//-------------------------------------------------------------------------------------
ftype = lag == 0 and hi > 0.5 and step == 1 ? "n ALL-PASS" : hi >= .5 and po <= 0 ? "n HIGH-PASS" : step == 0 ? " BAND-PASS" : hi > 0.5 and po == 0 ? " BAND-STOP" : " LOW-PASS"
warning = (ftype == " LOW-PASS" or ftype == " BAND-STOP") and step != 1
over = po > 50
//-------------------------------------------------------------------------------------
//Information Box
//-------------------------------------------------------------------------------------
N = "#.####"
lim = "------------------------------------------------------"
txt = lim + "\n" + " Filter Metrics" + "\n" + lim + "\n" + "\n" + "Lag : " + str.tostring(lag, N) + " Bars" + "\n" + "\n" + "Herfindahl Index : " + str.tostring(hi, N) + "\n" + "\n" + "Percentage Overshoot : " + str.tostring(po, N) + "%" + "\n" + "\n" + "Percentage Positive Weights : " + str.tostring(pw, N) + "%" + "\n" + "\n" + lim + "\n" + " Comments" + "\n" + lim + "\n" + (warning ? "" : "\n" + "It seems your filter is a" + ftype + " filter" + "\n") + (over ? "\n" + "⚠ " + "High Overshoots" + "\n" : "") + (warning ? "\n" + "⚠ " + "Weights does not add-up to 1" + "\n" : "")
label l = label.new(n, close, text=txt, color=color.black, style=label.style_label_left, textcolor=color.white, textalign=text.align_left)
label.delete(l[1])
//-------------------------------------------------------------------------------------
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.