Stepped Fibonacci Weighted Moving Average
"TA Basics: further "Steps" with our Moving Average" by RedKTrader, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TA Basics: further "Steps" with our Moving Average (v1.0), read 2026-10-12T16:19:25.811Z; 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.
TA Basics: further "Steps" with our Moving Average by RedKTrader, ported from Pine v4. Overlay indicator with 1 plot and 4 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
// ------------------------------------------------------------------------------------------------
// Original author: RedKTrader
// Original title: TA Basics: further "Steps" with our Moving Average
// 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(title="Stepped Fibonacci Weighted Moving Average", shorttitle="FiMA_Step", overlay=true)
// main Fib-WMA function
// this function calculates Fib(n)
// ============================================================================
fima(x, length) =>
numerator = 0.0
denom = 0.0
fibweight = 0.0
phi = (1 + math.sqrt(5)) / 2
for i = 0 to length - 1
fibweight := math.round(math.pow(phi, length - i) / math.sqrt(5))
numerator := numerator + x[i] * fibweight
denom := denom + fibweight
numerator / denom
// ============================================================================
// step function
// this function picks the step size based on the price range
// change and personalize these ranges as needed
// ============================================================================
step(x) =>
i = x < 1 ? 0.05 : x < 5 ? 0.25 : x < 20 ? 0.50 : x < 100 ? 1.00 : x < 300 ? 2.00 : x < 500 ? 5.00 : x < 1000 ? 10.0 : x < 5000 ? 20.0 : x < 10000 ? 50.0 : x < 20000 ? 100. : 200.0
i
// ============================================================================
//inputs
length = input(20, "Length")
data = input(close, "Source")
ex_s = input.int(3, "Extra Smoothing", minval=0)
s_option = input.float(title="Step [enter value, 0 = Auto, -1 = None]", defval=0.0, minval=-1.0)
s = s_option == 0.0 ? step(data) : s_option < 0 ? -1 : s_option
//Calculation
FiMA = fima(data, length)
// Apply extra smoothing, by doing a second FiMA pass using a small length
FiMAs = fima(FiMA, ex_s)
//Apply Stepping to final FiMAs Line
FiMAstep = s == -1 ? FiMAs : math.round(FiMAs / s) * s
//Plot
plot(FiMAstep, title="FiMA", color=color.yellow, linewidth=3)
This file is under the Mozilla Public License 2.0; it is a port of the original by RedKTrader, 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.