Fibonacci Weighted Moving Average v2
"TA Basics: Creating a Fibonacci Weighted Moving Average" by RedKTrader, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TA Basics: Creating a Fibonacci Weighted Moving Average (v3.0), read 2026-10-12T16:19:32.120Z; 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: Creating a Fibonacci Weighted Moving Average by RedKTrader, ported from Pine v4. Overlay indicator with 1 plot 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/
// © RedKTrader
// ------------------------------------------------------------------------------------------------
// Original author: RedKTrader
// Original title: TA Basics: Creating a Fibonacci Weighted 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="Fibonacci Weighted Moving Average v2", shorttitle="FiMA v2", overlay=true)
//main Fib-WMA function
// this function calculates Fib(n)
// utilizing the mathematical formula available here --> https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/
// Fn = {[(√5 + 1)/2] ^ n} / √5
// .... and we simplify it in code to 2 simpler parts:
// phi = (1 + sqrt(5)) / 2 --> this is a constant, so no need to calulcate each time
// fib(n) = round(pow(phi, n) / sqrt(5)) --> this determines the Fibonacci Sequence value for n
// ============================================================================
fima(_price, _length) =>
numerator = 0.0
denom = 0.0
float fibweight = 0.0
float k = 0.0
var float f = math.sqrt(5)
var float phi = math.phi
for i = 0 to _length - 1
k := math.pow(phi, _length - i)
//fibweight := round( k / f)
// remove round() function as it forces conversion of the float variable into integer and we hit maxval of integers too soon
fibweight := k / f
numerator := numerator + _price[i] * fibweight
denom := denom + fibweight
numerator / denom
// ============================================================================
//inputs
length = input.int(20, "Length", minval=1)
source = input(close, "Source")
ex_s = input.int(3, "Extra Smoothing", minval=1)
//Calculation
FiMA = fima(source, length)
// Apply extra smoothing
FiMAs = ta.wma(FiMA, ex_s)
//Plot
plot(FiMAs, 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.