L2 Sine-Weighted Moving Average (SWMA)

Jul 27, 2021

Static chart image
Support and Resistance
Signals
Moving Averages

The L2 Sine-Weighted Moving Average (SWMA) indicator provides a smoothed trend-following mechanism that utilizes a sine wave distribution to assign maximum weight to the middle of a data set, reducing lag while maintaining smoothness.

Usage

The Usage section describes how the script can be used, particularly for identifying trend direction and potential entry or exit points through moving average crossovers. Because the Sine-Weighted Moving Average emphasizes the center of the lookback period, it behaves similarly to a Triangular Moving Average (TMA) but with a more organic weight distribution based on a sine curve.

The indicator is typically used in the following ways:

  • Trend Identification: When the Fast SWMA is above the Slow SWMA, the trend is considered bullish (highlighted by a green cloud). When the Fast SWMA is below the Slow SWMA, the trend is considered bearish (highlighted by a red cloud).
  • Crossover Signals: The script automatically plots "BUY" labels when the Fast SWMA crosses above the Slow SWMA and "SELL" labels when it crosses below.
  • Support and Resistance: Traders can use the slow-period line as a dynamic level of support or resistance during established trends.

Details

The Sine-Weighted Moving Average was introduced by Patrick Lafferty in 1999. Unlike a Simple Moving Average (SMA), which weights all data points equally, or an Exponential Moving Average (EMA), which weights the most recent data most heavily, the SWMA uses the first half of a sine wave cycle (from 0 to pi) to determine weightings.

For an N-bar period, the weighting for each bar is calculated as sin(i * pi / (N+1)). This mathematical approach ensures that the most significant weight is placed on the middle data points of the lookback period. This construction helps filter out market noise and "outlier" volatility at the beginning or end of the lookback window, resulting in a curve that is often smoother than a standard SMA of the same length.

Settings

  • Price Source: Determines the price data used for the calculation (e.g., Close, Open, High, Low, HL2).
  • Fast Period Length: Sets the lookback period for the faster, more reactive SWMA line.
  • Slow Period Length: Sets the lookback period for the slower, trend-defining SWMA line.

FAQ

How do I interpret the colored background between the lines? The cloud between the Fast and Slow SWMA lines represents the current momentum. A green cloud indicates bullish momentum (Fast > Slow), while a red cloud indicates bearish momentum (Slow > Fast).

What makes SWMA different from a standard Moving Average? Standard moving averages usually front-load or evenly distribute weight; the SWMA "center-loads" the weight using a sine wave, which can provide a unique perspective on price action by focusing on the "heart" of the selected time window.

How can I access the L2 Sine-Weighted Moving Average (SWMA)? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.