All indicators

GMS: Moving Average Crossover Strategy

Mar 3, 2020

Static chart image
SignalsMoney ManagementMoving Averages

The GMS: Moving Average Crossover Strategy tool provides a versatile framework for generating and backtesting trading signals based on the intersection of two customizable moving averages combined with a robust trend-filtering mechanism.

Usage

The strategy is designed to identify momentum shifts by monitoring the crossover of a "Fast" and "Slow" moving average. Users can choose between four different calculation methods—SMA, EMA, WMA, and VWMA—for either moving average to suit different market conditions or asset classes.

The script allows for granular control over trade execution:

  • Directional Bias: Traders can toggle between "Long Only," "Short Only," or "Both" to align with their specific market outlook.
  • Trend Filtering: By enabling the Trend SMA Filter, the strategy will only initiate a Long position if the price is above the Trend SMA (or Short if below), helping to avoid counter-trend signals.
  • Risk Management: The strategy includes built-in Profit Target and Stop Loss inputs defined by percentages, allowing for automated exit management alongside the standard crossover exit logic.

Details

The strategy executes an entry when the primary moving average (MA1) crosses over or under the secondary moving average (MA2). If the trend filter is active, the script evaluates the relationship between the closing price and a Simple Moving Average of a specified length (defaulting to 200) before confirming an entry. It is important to note that the trend filter only applies to trade entries; exits are triggered either by a reverse crossover or by hitting the predefined profit/loss percentage thresholds.

The inclusion of Volume Weighted Moving Averages (VWMA) and Weighted Moving Averages (WMA) allows users to incorporate volume data and price sensitivity into the crossover logic, providing more technical depth than standard SMA/EMA systems.

Settings

  • Long Only or Short Only or Both?: Filters the strategy to only execute trades in the selected direction.
  • Which Moving Average? (1 & 2): Selects the calculation method (SMA, EMA, WMA, or VWMA) for the two crossover lines.
  • Moving Average Length (1 & 2): Sets the lookback period for the primary and secondary moving averages.
  • Trend SMA Filter?: Determines if price must be "Above" or "Below" the trend SMA for an entry to trigger, or if the filter should be ignored.
  • Trend SMA Length: Defines the lookback period for the filter SMA.
  • Profit Target On/Off: Enables or disables the percentage-based take-profit exit.
  • Profit Target %: The percentage gain required to trigger a profit-taking exit.
  • Stop Loss On/Off: Enables or disables the percentage-based stop-loss exit.
  • Stop Loss %: The percentage decline (expressed as a negative value) required to trigger a protective exit.

FAQ

Which moving average types are supported? The strategy supports Simple Moving Averages (SMA), Exponential Moving Averages (EMA), Weighted Moving Averages (WMA), and Volume Weighted Moving Averages (VWMA).

Does the trend filter affect trade exits? No, the trend filter is only checked during the entry phase. Once a trade is active, it will remain open until a reverse crossover occurs or the profit/loss targets are met, regardless of the price's position relative to the trend SMA.

How do I access this script? 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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.