Moving Average 50+200+365
Apr 7, 2018

The Moving Average 50+200+365 indicator plots three distinct Simple Moving Averages (SMA) to help traders identify short-, medium-, and long-term trend directions while providing automated alerts for crossover signals.
Usage
The Usage section describes how the script can be used to analyze market trends and momentum. By default, the indicator uses the 50, 200, and 365 periods, which are widely recognized benchmarks for institutional trend analysis.
- Trend Identification: Traders can use the orientation of the three lines to determine the prevailing market bias. When the price is above all three averages, the market is generally considered to be in a strong uptrend.
- Golden and Death Crosses: The interaction between the 50-period (short-term) and 200-period (medium-term) averages is often used to spot significant momentum shifts. A crossover of the 50 over the 200 is traditionally a bullish signal, while a crossunder is bearish.
- Long-Term Context: The 365-period average represents a full year of trading data (on daily charts), acting as a "north star" for the macro trend and providing significant dynamic support or resistance.
- Alerting System: The script includes built-in alert conditions that trigger at the close of a bar whenever any of the three moving averages intersect, allowing users to monitor trend changes without constant chart observation.
Details
The script calculates three Simple Moving Averages (SMA) based on user-defined lengths and price sources. The SMA is a non-weighted moving average that calculates the arithmetic mean of a set of prices over a specific number of periods.
The logic for crossovers is calculated using the ta.crossover and ta.crossunder functions in Pine Script. This refactored version, originally based on code by @Cupra and updated by LuxAlgo Quant Agent, ensures that alerts are optimized for performance and visual clarity. The visual output uses distinct colors for each average to differentiate between time horizons easily.
Settings
- Length 1: Sets the period for the first moving average (Default: 50).
- Source 1: Determines the price data used for the first average (Default: Close).
- Length 2: Sets the period for the second moving average (Default: 200).
- Source 2: Determines the price data used for the second average (Default: Close).
- Length 3: Sets the period for the third moving average (Default: 365).
- Source 3: Determines the price data used for the third average (Default: Close).
FAQ
What timeframes work best with this indicator?
While the 50, 200, and 365 settings are most common on the Daily (D) timeframe to represent quarterly and yearly trends, the indicator can be applied to any timeframe for intraday or long-term analysis.
Can I change the type of moving average to EMA?
This specific version uses the Simple Moving Average (SMA). To use Exponential Moving Averages (EMA), the underlying logic in the script would need to be adjusted to the ta.ema function.
How do I get access to the Moving Average 50+200+365?
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.