50/100/200 Moving Averages (Pine Script For Copy)
Jan 25, 2019

The 50/100/200 Moving Averages indicator plots three distinct simple moving averages on the chart to help traders identify long-term trend direction and potential dynamic support or resistance levels.
Usage
The Usage section describes how the script can be used. This tool is primarily utilized to determine the prevailing market trend by observing the orientation and crossover points of the 50, 100, and 200-period averages.
- Trend Identification: When price remains above all three moving averages and the shorter-term averages (50) are above the longer-term ones (200), the market is considered to be in a structural uptrend. Conversely, price below these averages indicates a downtrend.
- Support and Resistance: These specific lengths are widely watched by institutional traders, often resulting in price reactions or "bounces" when the market tests the moving average lines.
- Crossovers: The script includes logic for monitoring crossovers between the 50 and 100-period averages. A "Golden Cross" or "Death Cross" involving these levels can signal a shift in medium-to-long-term momentum.
Details
The script calculates three Simple Moving Averages (SMA) based on the closing price of each bar. The SMA is a non-weighted calculation that averages the price data over the specified lookback period, providing a smoothed line that filters out short-term market noise.
The 50-period SMA represents medium-term momentum, the 100-period SMA represents intermediate trend strength, and the 200-period SMA is a standard benchmark for secular bull or bear market cycles. The script is optimized with Pine Script v6 standards and includes built-in alert conditions for crossovers between the first two moving averages to assist in automated trend monitoring.
Settings
- SMA 1 Length: Sets the lookback period for the first moving average (defaulted to 50).
- SMA 2 Length: Sets the lookback period for the second moving average (defaulted to 100).
- SMA 3 Length: Sets the lookback period for the third moving average (defaulted to 200).
FAQ
How do I modify the moving average type from SMA to EMA?
To change the calculation type, you can replace the ta.sma function in the script code with ta.ema for Exponential Moving Averages or ta.wma for Weighted Moving Averages.
Can I set alerts for the 200-period moving average? Yes, while the default alerts focus on the 50/100 crossover, the code can be adjusted to trigger alerts when the price crosses the 200 SMA or when the 50 SMA crosses the 200 SMA.
How do I access the 50/100/200 Moving Averages indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.