VIDYA
"Variable Index Dynamic Average VIDYA" by KivancOzbilgic, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Variable Index Dynamic Average VIDYA (v1.0), read 2026-10-12T16:05:42.919Z; 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.
Variable Index Dynamic Average VIDYA by KivancOzbilgic, 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/
// © KivancOzbilgic
// ------------------------------------------------------------------------------------------------
// Original author: KivancOzbilgic
// Original title: Variable Index Dynamic Average VIDYA
// 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("VIDYA", overlay=true)
src = input(close, title="Source")
pds = input(9, "Length")
fixCMO = input.bool(title="Fixed CMO Length (9)?", defval=true)
select = input.bool(title="Calculation Method: CMO/StDev?", defval=true)
alpha = 2 / (pds + 1)
momm = ta.change(src)
f1(m) => m >= 0.0 ? m : 0.0
f2(m) => m >= 0.0 ? 0.0 : -m
m1 = f1(momm)
m2 = f2(momm)
sm1 = fixCMO ? math.sum(m1, 9) : math.sum(m1, pds)
sm2 = fixCMO ? math.sum(m2, 9) : math.sum(m2, pds)
percent(nom, div) => 100 * nom / div
chandeMO = nz(percent(sm1 - sm2, sm1 + sm2))
k = select ? math.abs(chandeMO) / 100 : ta.stdev(src, pds)
VIDYA = 0.0
VIDYA := nz(alpha * k * src) + (1 - alpha * k) * nz(VIDYA[1])
col12 = VIDYA > VIDYA[1]
col32 = VIDYA < VIDYA[1]
color2 = col12 ? #001AE1 : col32 ? color.maroon : color.blue
plot(VIDYA, "VAR", color2, 2)
alertcondition(ta.cross(VIDYA, VIDYA[1]), title="Color ALARM!", message="VIDYA has changed color!")
This file is under the Mozilla Public License 2.0; it is a port of the original by KivancOzbilgic, 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.