20 / 200 SMA Strategy -
May 17, 2026

The 20 / 200 SMA Strategy indicator provides a comprehensive trend-following framework that utilizes the relationship between 20-period and 200-period simple moving averages to identify high-probability entry points. This tool is designed to capture market momentum by aligning short-term price action with long-term trend direction through various entry modes and robust risk management filters.
Usage
The Usage section describes how the script can be used to identify trend-following opportunities. The strategy relies on the 20 SMA (Fast) and 200 SMA (Slow) to establish a bias; for instance, when the 20 SMA is above the 200 SMA, the script prioritizes long setups.
Entry Modes
The script offers three distinct entry methods to suit different trading styles:
- Original Cross Entry: Generates a signal when the 20 SMA crosses the 200 SMA and price subsequently closes on the trending side of the 20 SMA.
- Trend Pullback Entry: Designed for established trends, entering when the price pulls back and then crosses back over the 20 SMA in the direction of the main trend.
- Relaxed Testing Entry: A flexible mode that triggers whenever price and the 20 SMA are correctly aligned with the 200 SMA, useful for trend continuation testing.
Details
The script's execution is rooted in classic moving average crossover theory but enhances it with advanced exit logic. A unique feature is the "Last Opposing Candle Beyond 200 SMA" stop-loss mode, which dynamically places stops behind the most recent counter-trend candle located on the far side of the slow moving average. This ensures stops are placed at structural exhaustion points rather than arbitrary levels. Additionally, the script employs "Armed" logic, which tracks the time elapsed since a crossover to ensure entries occur within a user-defined window.
Settings
Main Settings
- Trade Direction: Sets the strategy to take Long only, Short only, or both directions.
- Fast/Slow SMA Length: Defines the lookback periods for the two simple moving averages.
- Entry Strictness: Selects between Original Cross, Trend Pullback, or Relaxed entry logic.
- Bars Allowed After SMA Cross: Limits the window of time for an entry to occur after a fresh crossover.
Risk Settings
- Take Profit Points: Sets a fixed profit target in points.
- Stop Loss Method: Choose between a structural stop (Opposing candle), a fixed point stop, or a recent swing high/low stop.
- Opposing Candle Lookback: Determines how far back the script searches for a counter-trend candle to set a stop loss.
Optional Filters
- Use 200 SMA Slope Filter: Requires the 200 SMA to be heading in the direction of the trade.
- Use Candle Color Filter: Ensures the entry candle color matches the trade direction.
- Avoid Entries Too Far From 20 SMA: A volatility filter that prevents entering trades when the price has extended too far from the fast average.
FAQ
How do I adjust the strategy for different timeframes? Users should adjust the "Bars Allowed After SMA Cross" and "Max Distance From 20 SMA" settings to account for the increased volatility and candle duration of higher timeframes.
What is the purpose of the "Armed" status? The "Armed" status indicates that a moving average crossover has occurred, but the specific price action conditions for an entry have not yet been met, preparing the script for a potential signal.
How can I access the 20 / 200 SMA Strategy? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
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.

