All indicators

Ultimate Moving Average Strategy

Jul 11, 2018

Static chart image
SignalsMoving AveragesTrailing-Stop

The Ultimate Moving Average Strategy indicator provides a versatile backtesting framework that utilizes multi-timeframe moving averages and directional color-coding to identify trend shifts and execute automated trades.

Usage

The Ultimate Moving Average Strategy is designed to capture trend reversals by monitoring the slope and interaction of various moving average types. It is particularly effective on higher timeframes, such as the 8-hour chart or higher, where market noise is reduced.

The strategy executes long entries when the primary moving average begins to trend upward (based on a user-defined smoothing period) and enters short positions when the average trends downward. Users can optionally enable a second moving average to visualize crossovers or act as a secondary filter.

Multi-Timeframe Analysis

The tool allows users to calculate moving averages based on a timeframe higher than the current chart. This enables "top-down" analysis, where a trader can view Daily trend data while executing trades on lower intraday intervals.

Directional Smoothing

To reduce "whipsaws" (false signals), the strategy includes a smoothing parameter. Instead of reacting to a single bar's change in direction, the color and signal only flip when the current value is higher or lower than its value X bars ago.

Details

The script is a strategy conversion of the CM_Ultimate_MA_MTF indicator, originally developed by @Virtual_Machinist. It integrates several types of moving average calculations into a single logic block:

  • Standard Types: SMA, EMA, WMA, RMA, and VWMA.
  • Advanced Types: Hull Moving Average (HMA) and Triple Exponential Moving Average (TEMA).
  • Trailing Stop Mechanism: Includes a built-in trailing stop-loss feature using points and offset values to protect equity during trending phases.

The core logic evaluates the relationship between out and out[smoothe]. If the current value is greater than the value at the smoothing offset, the trend is considered bullish. If it is lower, it is considered bearish.

Settings

Primary MA Settings

  • Use Current Chart Resolution?: When enabled, the MA uses the current chart's timeframe. When disabled, it uses the custom timeframe selected below.
  • Use Different Timeframe?: Specifies the timeframe for MA calculation (e.g., Daily, Weekly).
  • Moving Average Length: The lookback period for the primary calculation.
  • MA Type: Selects the calculation method (1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA).
  • Change Color Based On Direction?: Toggles the visual color change when the trend shifts.
  • Color Smoothing: Determines the number of bars to look back when checking for a change in direction.

Secondary MA & Crossings

  • Optional 2nd Moving Average: Enables a secondary MA on the chart.
  • Moving Average Length - Optional 2nd MA: The lookback period for the secondary MA.
  • Show Dots on Cross of Both MA's: Plots a cross icon on the chart when the two moving averages intersect.

Strategy & Risk Management

  • Use Trailing Stop?: Toggles the trailing stop-loss logic.
  • Stop Loss Trail Points: The distance in points required to activate the trail.
  • Stop Loss Trail Offset: The distance in points to maintain the stop behind the price.

FAQ

How do I use the multi-timeframe feature? To use a different timeframe, uncheck "Use Current Chart Resolution?" in the settings and select your desired timeframe (e.g., "D" for Daily) in the "Use Different Timeframe?" dropdown.

Which moving average type is best for reducing lag? The Hull Moving Average (Option 4) and TEMA (Option 7) are specifically designed to reduce the lag typically found in standard SMAs.

How can I access the Ultimate Moving Average Strategy? 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.