Links: |TradingView|TradeStation|NinjaTrader|MT4|MT5|Python|Excel|
TradeStation: June 2025
In the article “Making A Better Oscillator” in this issue, John Ehlers introduces a new indicator he calls the cybernetic oscillator. This indicator applies a multistep filter. The data is smoothed using a highpass filter ($HighPass function), which is then smoothed using the lowpass filter ($SuperSmoother function). The result is then scaled to its RMS (root mean squared).
Code: Select all
{
TASC JUN 2025
Cybernetic Oscillator
(C) 2025 John F. Ehlers
}
inputs:
HPLength( 30 ),
LPLength( 20 );
variables:
HP( 0 ),
LP( 0 ),
RMS( 0 ),
CyberneticOsc( 0 );
HP = $HighPass(Close, HPLength);
LP = $SuperSmoother(HP, LPLength);
RMS = $RMS(LP, 100);
if RMS <> 0 then
CyberneticOsc = LP / RMS;
Plot1( CyberneticOsc, "Cybernetic Osc" );
Plot2( 0, "Zero Line" );
Function: $HighPass
{
$HighPass Function
(C) 2004-2025 John F. Ehlers
}
inputs:
Price(numericseries),
Period(numericsimple);
variables:
a1( 0 ),
b1( 0 ),
c1( 0 ),
c2( 0 ),
c3( 0 );
a1 = ExpValue(-1.414 * 3.14159 / Period);
b1 = 2 * a1 * Cosine(1.414 * 180 / Period);
c2 = b1;
c3 = -a1 * a1;
c1 = (1 + c2 - c3) / 4;
if CurrentBar >= 4 then
$HighPass = c1*(Price - 2 * Price[1] + Price[2]) +
c2 * $HighPass[1] + c3 * $HighPass[2];
if Currentbar < 4 then
$HighPass = 0;
Function: $SuperSmoother
{
$SuperSmoother Function
(C) 2004-2025 John F. Ehlers
}
inputs:
Price(numericseries),
Period(numericsimple);
variables:
a1( 0 ),
b1( 0 ),
c1( 0 ),
c2( 0 ),
c3( 0 );
a1 = ExpValue(-1.414 * 3.14159 / Period);
b1 = 2 * a1 * Cosine(1.414 * 180 / Period);
c2 = b1;
c3 = -a1 * a1;
c1 = 1 - c2 - c3;
if CurrentBar >= 4 then
$SuperSmoother = c1*(Price + Price[1]) / 2
+ c2 * $SuperSmoother[1] + c3 * $SuperSmoother[2];
if CurrentBar < 4 then
$SuperSmoother = Price;
Indicator: $RMS
{
RMS Function
(C) 2015-2025 John F. Ehlers
}
inputs:
Price( numericseries ),
Length( numericsimple );
variables:
SumSq( 0 ),
count( 0 );
SumSq = 0;
for count = 0 to Length - 1
begin
SumSq = SumSq + Price[count] * Price[count];
end;
If SumSq <> 0 then
$RMS = SquareRoot(SumSq / Length);