Simple Moving Averages (20, 50, 200)

Aug 20, 2022

Static chart image
Support and Resistance
Signals
Moving Averages

The Simple Moving Averages (20, 50, 200) indicator plots three essential trend-following lines on a single chart to help traders identify short, medium, and long-term market trends and potential reversal points.

Usage

The Usage section describes how the script can be used to interpret market momentum and trend direction. Traders typically use these specific moving average lengths to categorize market cycles:

  • SMA 20 (Short-term): Used to gauge immediate momentum and short-term price fluctuations.
  • SMA 50 (Medium-term): Serves as a standard benchmark for intermediate trend direction.
  • SMA 200 (Long-term): Widely regarded by institutional traders to determine the overall primary trend of an asset.

Examples of Interpretation:

  • Trend Confirmation: When the price is consistently above all three averages, the asset is considered to be in a strong bullish trend. Conversely, price action below these averages suggests a bearish trend.
  • Crossover Signals: The indicator includes built-in logic for "Golden Crosses" and "Death Crosses." For example, when the 50-period SMA crosses above the 200-period SMA, it is often interpreted as a long-term bullish signal.
  • Dynamic Support and Resistance: These averages often act as floors or ceilings where price may bounce or face rejection during a trend.

Details

The script calculates the simple moving average (SMA) by taking the sum of the closing prices over the specified periods (20, 50, and 200) and dividing that sum by the number of time periods.

The implementation features optimized alert conditions for crossover events. This includes alerts for the 20 SMA crossing the 50 SMA, and the 50 SMA crossing the 200 SMA. These alerts are set to trigger once per bar close to ensure signal validity. This tool was originally developed by @ayejay_ and has been refactored for performance and visual clarity.

Settings

  • SMA(20) Plot: Adjust the visibility and color of the 20-period moving average line (Default: Blue).
  • SMA(50) Plot: Adjust the visibility and color of the 50-period moving average line (Default: Red).
  • SMA(200) Plot: Adjust the visibility and color of the 200-period moving average line (Default: Green).
  • Alerts: The script includes hardcoded logic for crossovers between the 20/50 SMAs and the 50/200 SMAs which can be configured via the TradingView Alert menu.

FAQ

What is the significance of the 200-day SMA? The 200-day SMA is a key technical indicator used by traders and market analysts to determine the health of the long-term trend. It is often used to differentiate between a healthy bull market and a long-term bear market.

Does this indicator provide alerts? Yes, the script includes specific alert conditions for crossovers between the short-term and medium-term averages, as well as the medium-term and long-term averages.

How do I access the Simple Moving Averages (20, 50, 200) tool? 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
ninjatraderNinjaTrader
metatrader4MetaTrader 4/5
thinkorswimThinkorswim

Unlock Unlimited Access to the LuxAlgo Library

Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.

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.