Simple Moving Average with Regime Detection by iGrey.Trading
Nov 23, 2024

The Simple Moving Average with Regime Detection indicator provides a comprehensive framework for identifying market trends and regimes using a dual Simple Moving Average (SMA) system. This tool simplifies trend analysis by color-coding price action and providing real-time metrics to help traders distinguish between bullish and bearish market environments.
Usage
The Usage section describes how the script can be used to navigate different market cycles. Users can apply the indicator to any timeframe to instantly visualize the current market regime.
- Regime Identification: The indicator defines a Bullish regime when the price is above the 200 SMA (default) and a Bearish regime when the price is below it. The candles are automatically colored green for bullish trends and red for bearish trends.
- Metrics Dashboard: A customizable on-screen table provides live data, including the current regime status, the percentage distance from the price to both the short-term and long-term SMAs, and the duration of the current regime in bars.
- Trend Confirmation: Traders can use the 50 SMA (short-term) in conjunction with the 200 SMA (long-term) to identify potential golden crosses or death crosses as secondary confirmation for trend strength or reversals.
Details
The script utilizes two Simple Moving Averages to establish a "Regime Filter." The primary logic is based on price location relative to the long-term SMA (Regime MA). If the price closes above the Regime MA, the system enters a bullish state; if it closes below, it enters a bearish state.
The indicator calculates "Regime Duration" by counting the number of consecutive bars the price has remained in its current state. Additionally, it calculates the percentage deviation of the current price from both moving averages, providing insight into overextended market conditions or potential mean reversion opportunities. Alerts are integrated to notify users the moment a regime transition occurs.
Settings
Table Settings
- Table Position: Determines where the metrics dashboard appears on the chart (Top Right, Top Left, Bottom Right, or Bottom Left).
- Show Table: Toggles the visibility of the metrics dashboard.
- Table Background Color: Sets the transparency and color of the table background.
- Text Size: Adjusts the font size within the table (Tiny to Huge).
SMA Settings
- Length: Sets the period for the short-term Simple Moving Average (default: 50).
- Source: Determines the price data used for the short-term SMA calculation (default: Close).
Regime Settings
- Regime Filter Length: Sets the period for the long-term SMA used for regime detection (default: 200).
- Regime Filter Source: Determines the price data used for the long-term SMA calculation (default: Close).
FAQ
How do I interpret the candle colors? Green candles signify a bullish market regime where the price is trading above the long-term SMA, while red candles signify a bearish regime where the price is trading below the long-term SMA.
Can I change the moving average periods? Yes, you can adjust both the short-term SMA and the Regime Filter Length in the indicator settings to suit different assets or trading styles.
How can I access the Simple Moving Average with Regime Detection? 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.