Even Better Sinewave

Calculate Ehlers’ Even Better Sinewave: an oscillator between -1 and 1 that shows whether the prices move in a cycle or a trend and where they are in the cycle.

The Even Better Sinewave of Ehlers (2013) removes the trend with a one-pole high-pass filter, smooths the remaining cycles with a SuperSmoother and divides their average over three periods by the square root of their power over the same periods. The result swings between -1 and 1 like a sine wave while the price cycles and stays near 1 (or -1) while it trends up (or down), so it tells a cycle from a trend and marks the turns of the cycle.

The formula is as follows:

\[\alpha = \frac{1 - \sin\left(\frac{360}{\text{Window}}\right)}{\cos\left(\frac{360}{\text{Window}}\right)}\] \[\text{HP} = 0.5 \cdot (1 + \alpha) \cdot (\text{Price} - \operatorname{Price}(t-1)) + \alpha \cdot \operatorname{HP}(t-1)\] \[a = \exp\left(- \frac{\sqrt{2} \cdot \pi}{\text{Smoothing Window}}\right),\;\; b = 2 \cdot a \cdot \cos\left(\frac{\sqrt{2} \cdot 180}{\text{Smoothing Window}}\right),\;\; c_{2} = b,\;\; c_{3} = - a^{2}\;\;\text{and}\;\; c_{1} = 1 - c_{2} - c_{3}\] \[\text{Filter} = \frac{c_{1} \cdot (\text{HP} + \operatorname{HP}(t-1))}{2} + c_{2} \cdot \operatorname{Filter}(t-1) + c_{3} \cdot \operatorname{Filter}(t-2)\] \[\text{Wave} = \frac{\text{Filter} + \operatorname{Filter}(t-1) + \operatorname{Filter}(t-2)}{3}\] \[\text{Power} = \frac{\text{Filter}^{2} + \operatorname{Filter}(t-1)^{2} + \operatorname{Filter}(t-2)^{2}}{3}\] \[\text{Even Better Sinewave} = \frac{\text{Wave}}{\sqrt{\text{Power}}}\]

Example · AAPL, MSFT · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_even_better_sinewave:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_even_better_sinewave()

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

What did Ehlers' Even Better Sinewave of Apple and Microsoft show in 2025?

Which returns:

Parameters

get_even_better_sinewave accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintThe cutoff period of the high-pass filter, the longest cycle kept. Defaults to 40.20
smooth_windowintThe critical period of the SuperSmoother. Defaults to 10.5
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the Even Better Sinewave. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Ehlers, J.F. (2013). “Cycle Analytics for Traders: Advanced Technical Trading Concepts.” John Wiley & Sons.
  • Library Referenced against pandas-ta-classic’s ebsw
Share