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.
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.

