TradingView indicator calculations

Ehlers Cyber Cycle indicator: extraction and signals

The Cyber Cycle indicator uses a four-bar price smoother and a recursive high-pass filter to emphasize oscillation around a changing trend. John Ehlers described it in Cybernetic Analysis for Stocks and Futures. This page uses fixed alpha = 0.07 and the preceding Cycle value as its trigger. A trigger crossing detects a turn in the filtered series; it does not establish that price has reversed. The synthetic and historical examples below show that distinction.

See the decision guide

Follow the public recurrence

Let P be the chosen price series, S its smoothed value, C the cycle and a the fixed alpha. Brackets count earlier bars. Ehlers publishes the four-bar weights and the recursive filter; Sierra Chart documents the same core recurrence. This example retains the one-bar trigger from the book rather than adopting Sierra Chart's separately smoothed trigger.

  • Arithmetic check with hypothetical established states: S = 103, S[1] = 102, S[2] = 100, C[1] = 2 and C[2] = 1 gives C = −0.931225 + 3.72 − 0.8649 = 1.923875. The trigger is 2.
  • The weights sum to one. A constant input stays constant after smoothing, then its second difference is zero. A linear ramp also has zero second difference; with zero startup cycle values, its cycle stays zero even though price trends.
  • A larger alpha reduces the persistence of the recursive state. It also changes frequency response and amplitude. Do not equate alpha to the number of bars in a measured market cycle.
StageCalculation
InputP = (high + low)/2
SmootherS = (P + 2P[1] + 2P[2] + P[3])/6
Cycle recurrenceC = (1 − a/2)² × (S − 2S[1] + S[2]) + 2(1 − a)C[1] − (1 − a)²C[2]
Delayed triggerT = C[1]
Coefficients at a = 0.070.931225, 1.86 and −0.8649

Separate startup from convergence

The code below numbers samples from zero. It sets C to zero at indices 0 and 1, uses (P − 2P[1] + P[2])/4 at indices 2 through 5, and starts the full recurrence at index 6. This declares the missing-history policy instead of silently substituting prices. The plots and alerts hide the first 150 bars by default; calculations continue throughout.

  • A seed error follows the homogeneous recurrence with repeated root 1 − a. Its general form is (A + Bn)(1 − a)^n, so the warm-up is not simply six bars or one exponential half-life.
  • At a = 0.07 the root is 0.93. Smaller alpha retains startup differences longer. A 150-bar display gate is a declared example setting, not a convergence guarantee for every alpha, seed or tolerance.
  • Load additional earlier history and compare the same later timestamps. Keep source, alpha and trigger definition fixed. Document the remaining difference against a tolerance appropriate to the instrument's price scale.
  • Use a continuous, valid input. An upstream indicator with missing values can propagate unavailable values through this recurrence; the sample does not fabricate replacement data or implement a reset after gaps.

Measure phase on an artificial 20-bar wave

This reproducible fixture feeds P[n] = 100 + 10 sin(2πn/20) from n = 0 with the startup rule above and a = 0.07. It is synthetic data, not a backtest. The table rounds to six decimals after computing at full precision. Select the artificial-cycle input in the code and inspect Sample index in the Data Window.

  • The down crossing occurs one sample after the sampled peak, and the up crossing one sample after the trough. The small midpoint mismatch and reduced amplitude show that the output is not an exact copy of the input wave.
  • For this steady 20-bar wave, the frequency response has amplitude gain approximately 0.907854 and phase approximately −0.0210 radians, equivalent to about 0.067 bar of phase delay. That calculation is frequency-specific; it is not a zero-lag claim for market data.
  • The one-bar trigger adds its own comparison delay. A cycle can cross its trigger while staying far above or below zero. A zero crossing and a trigger crossing are different events.
nInput PCycle CTrigger C[1]Observation
160100.000000−0.193167−2.988805Input crosses its midpoint upward
165110.0000009.0747818.571487Input and sampled cycle peak
166109.5105658.6895929.074781Cycle crosses below trigger
170100.0000000.1894632.984845Input crosses its midpoint downward
17590.000000−9.077435−8.574325Input and sampled cycle trough
17690.489435−8.692075−9.077435Cycle crosses above trigger

Compare with a real trend that does not obey the wave

The following calculation uses Binance spot BTCUSDT daily candles, UTC, from its public monthly archive. Inputs run from October 1, 2023 through March 31, 2024: 183 consecutive bars, (high + low)/2, alpha 0.07 and the same startup rule. These are local calculations from exchange data, not claimed TradingView observations. Values are in USDT and rounded to two decimals.

  • The March 3 down crossing did not mark a sustained downward price move: the next close rose from 63,113.97 to 68,245.71. The March 9 and 10 crossings also reversed direction on consecutive candles. This is a concrete failure of treating every filtered turn as a trade reversal.
  • A smooth sine wave has a stable period and amplitude. Real prices contain changing trends, jumps and several timescales at once. There is no single known market phase against which to assign the sine fixture's delay.
  • To reproduce on TradingView, use standard BINANCE:BTCUSDT daily candles and compare the input high/low first. The October 1 starting state matters. A chart loading more history can differ; compare later values after documenting that difference. No return or win-rate estimate is derived from this selected diagnostic window.
UTC dateCloseCycleTriggerEvent
2024-03-0261,987.286,219.956,170.38Cycle still rising
2024-03-0363,113.975,352.176,219.95Down crossing
2024-03-0468,245.714,855.185,352.17Close rises despite falling cycle
2024-03-0968,313.274,020.653,916.52Up crossing
2024-03-1068,955.883,810.384,020.65Down crossing the next day
2024-03-1172,078.103,436.813,810.38Close rises again

Audit the calculation in Pine Script v6

Paste this indicator into the Pine Editor. It calculates on every update but plots Cycle and Trigger only after the display gate and bar confirmation. The market-source default is hl2. Artificial mode replaces that source with the fixture; switch it off before interpreting an alert as a market event.

  • An upward event requires C > T now and C[1] ≤ T[1] on the preceding bar; downward uses the opposite inequalities. Equality alone is not a crossing.
  • The developing bar can change high, low and therefore hl2. Requiring barstate.isconfirmed prevents these conditions from firing before the current chart bar closes. It does not correct bad source data or remove filtering delay.
  • Create the TradingView alert explicitly and use Once Per Bar Close. Changing script settings after creating an alert requires reviewing or recreating its saved configuration.
Fixed-alpha calculation with explicit seeds, a delayed trigger, diagnostic Data Window values and confirmed-bar alert conditions. No strategy orders are placed.pine
//@version=6
indicator("Cyber Cycle calculation audit", overlay = false, precision = 6)
alpha = input.float(0.07, "Alpha", minval = 0.01, maxval = 0.99, step = 0.01)
source = input.source(hl2, "Market source")
useSine = input.bool(false, "Use artificial 20-bar cycle")
warmup = input.int(150, "Hide first bars", minval = 7)
p = useSine ? 100.0 + 10.0 * math.sin(2.0 * math.pi * bar_index / 20.0) : source
s = (p + 2.0 * p[1] + 2.0 * p[2] + p[3]) / 6.0
float cycle = 0.0
if bar_index >= 2 and bar_index < 6
    cycle := (p - 2.0 * p[1] + p[2]) / 4.0
else if bar_index >= 6
    cycle := math.pow(1.0 - alpha / 2.0, 2) * (s - 2.0 * s[1] + s[2]) + 2.0 * (1.0 - alpha) * cycle[1] - math.pow(1.0 - alpha, 2) * cycle[2]
trigger = cycle[1]
crossUp = ta.crossover(cycle, trigger)
crossDown = ta.crossunder(cycle, trigger)
ready = bar_index >= warmup and barstate.isconfirmed
plot(ready ? cycle : na, "Cycle", color = color.blue, linewidth = 2)
plot(ready ? trigger : na, "Previous cycle", color = color.orange)
hline(0, "Zero", color = color.gray)
plot(p, "Input", display = display.data_window)
plot(s, "Smoothed input", display = display.data_window)
plot(bar_index, "Sample index", display = display.data_window)
alertcondition(ready and crossUp, "Cycle turns up", "Confirmed Cyber Cycle upward trigger crossing")
alertcondition(ready and crossDown, "Cycle turns down", "Confirmed Cyber Cycle downward trigger crossing")

Keep Cyber Cycle distinct from other Ehlers tools

This page covers a fixed-coefficient cycle series in price units. A Sine Wave indicator maps an estimated cycle phase to sine and lead-sine outputs; it is a different output and calculation. A Roofing Filter combines filtering stages to retain a chosen frequency region. Neither name makes its numerical values interchangeable with this Cyber Cycle.

  • An adaptive Cyber Cycle changes its coefficient using an estimated period. Stochastic or Fisher variants transform the result. Match the full formula before expecting any of these to reproduce the table.
  • A smoothed trigger, such as the one in Sierra Chart's study, is not C[1]. It can cross on different bars even when the underlying cycle agrees.
  • Raw cycle values have no universal overbought or oversold boundary. Multiplying all input prices by two multiplies both cycle and trigger by two under the same startup rule.

Give Pineify the version and the checks

Ask the Pine Script AI Coding Agent to draft or review the public recurrence with hl2, alpha 0.07, the stated startup indices, C[1] as trigger and confirmed-bar events. Include the synthetic table and ask for intermediate Data Window outputs. Request a syntax check, then compare the resulting values with your selected TradingView feed before adding alerts.

  • Provide a formula or code you are entitled to use. A named protected TradingView script is not enough to reconstruct its proprietary calculation.
  • If converting this into a strategy, specify entries, exits, sizing, execution timing, fees and slippage separately. Neither a successful syntax check nor a matched indicator table establishes profitability.
Where Pineify fits

Pine Script AI Coding Agent

Draft or review an explicit Cyber Cycle calculation, its initialization and confirmed-bar conditions, then check the resulting source and values.

Draft a Cyber Cycle calculation

Frequently asked questions

Educational information, not investment advice. Synthetic examples and selected historical calculations are diagnostics, not a performance study. Indicator crossings and syntax validation do not guarantee trading returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.