Untitled
"TASC 2025.06 Cybernetic Oscillator" by PineCodersTASC, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TASC 2025.06 Cybernetic Oscillator (v1.0), read 2026-11-15T18:30:36.898Z; source language v6.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
TASC 2025.06 Cybernetic Oscillator by PineCodersTASC, ported from Pine v6. Pane indicator with 3 plots, 2 fills, 1 level and 6 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2025-05-14; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// TASC Issue: June 2025
// Article: The Cybernetic Oscillator For More Flexibility
// Making A Better Oscillator
// Article By: John F. Ehlers
// Language: Pine-compatible v6
// Provided By: PineCoders, for tradingview.com
// ------------------------------------------------------------------------------------------------
// Original author: PineCodersTASC
// Original title: TASC 2025.06 Cybernetic Oscillator
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 6
// Fetched: 2026-11-15
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=6
TITLE = "TASC 2025.06 Cybernetic Oscillator"
S_TITLE = "CO"
indicator(TITLE, S_TITLE)
//#region --- Enum and inputs ---
// @enum An enumeration of possible display styles.
// @variable The source series to process.
float srcInput = input.source(close, "Source series:")
// @variable The highpass filter critical period.
int hpInput = input.int(30, "Highpass period:", 3)
// @variable The lowpass filter critical period.
int lpInput = input.int(20, "Lowpass period:", 3)
// @variable The number of bars in the RMS calculation.
int rmsInput = input.int(100, "RMS length:", 1)
// @variable A named value for the display style.
string styleInput = input.string("Trend", "Display style:", options=["Trend", "Threshold"])
// @variable The absolute threshold for the "Threshold" display style.
float thInput = input.float(1, "Threshold:", minval=0, step=0.1)
// Raise a runtime error if `hpInput` is less than `lpInput`.
if hpInput < lpInput
runtime.error("The highpass period cannot be less than the lowpass period.")
//#endregion
//#region --- Functions ---
// @function Calculates coefficients for the `hp()` and `ss()` functions.
// @param period The critical period of the filter.
// @param isHp If `true`, the coefficients are for a highpass filter. Otherwise,
// they are for a lowpass filter.
// @returns A tuple containing the highpass or lowpass filter coefficients.
coefs(simple int period, simple bool isHp) =>
var float a0 = 1.414 * math.pi / period
var float a1 = math.exp(-a0)
var float c2 = 2.0 * a1 * math.cos(a0)
var float c3 = -a1 * a1
var float c1 = isHp ? (1.0 + c2 - c3) * 0.25 : 1.0 - c2 - c3
[c1, c2, c3]
// @function Calculates a second-order highpass filter.
// @param source The series of values to process.
// @param period The length of the filter's critical period.
// @returns The filtered `source` value.
hp(float source, simple int period) =>
var float result = 0.0
if bar_index >= 4
[c1, c2, c3] = coefs(period, true)
result := c1 * (source - 2.0 * source[1] + source[2]) + c2 * nz(result[1]) + c3 * nz(result[2])
result
// @function Calculates a Super Smoother filter (second-order lowpass).
// @param source The series of values to process.
// @param period The length of the filter's critical period.
// @returns The filtered `source` value.
ss(float source, simple int period) =>
var float result = source
if bar_index >= 4
[c1, c2, c3] = coefs(period, false)
result := c1 * 0.5 * (source + source[1]) + c2 * nz(result[1]) + c3 * nz(result[2])
result
// @function Calculates the root mean square (RMS) of a series.
// @param source The series of values to process.
// @param length The number of bars in the calculation.
// @returns The RMS of the `source` values over `length` bars.
rms(float source, simple int length) =>
math.sqrt(ta.sma(source * source, length))
// @function Calculates the Cybernetic Oscillator.
// @param source The series of values to process.
// @param hpPeriod The highpass filter critical period.
// @param lpPeriod The lowpass filter critical period.
// @param rmsInput The number of bars in the RMS calculation.
// @returns The Cybernetic Oscillator of `source` with specified settings.
co(float source, simple int hpPeriod, simple int lpPeriod, simple int rmsInput) =>
var float result = 0.0
float hp = hp(source, hpPeriod)
float lp = ss(hp, lpPeriod)
float rms = rms(lp, rmsInput)
if rms != 0.0
result := lp / rms
result
//#endregion
//#region --- Calculations and display ---
// @variable Is `true` if the selected style is `style.Threshold`; `false` otherwise.
bool isThresh = styleInput == "Threshold"
// @variable The Cybernetic Oscillator of the `srcInput` series with specified settings.
float osc = co(srcInput, hpInput, lpInput, rmsInput)
// Plot the `osc` value with a color based on the chosen display style.
p0 = plot(osc, "Cybernetic Oscillator", isThresh ? #aa9b9b : osc > 0.0 ? #4caf4f : #af4e4c, 2)
// Plot the upper and lower thresholds.
pu = plot(isThresh ? thInput : na, "Upper threshold", #b2b5be80)
pl = plot(isThresh ? -thInput : na, "Lower threshold", #b2b5be80)
// Fill the space between the plots based on the `osc` and `thInput` values.
fill(p0, pu, isThresh and osc > thInput ? #af4e4c93 : na, title="Upper fill")
fill(p0, pl, isThresh and osc < -thInput ? #4caf4f93 : na, title="Lower fill")
// Create a horizontal line at 0.
hline(0)
//#endregion
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCodersTASC, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
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.