Skip to content
All library documents

Configurable Moving Average Crossover Strategies with Fee-Aware Backtests

Article TradingView scripts

Summary

This strategy tutorial shows how to build a system from three configurable moving averages. Each average can use a different type, source, lookback period, and chart interval. The strategy can trade selected pairwise crossovers, drawing on simple, exponential, weighted, smoothed, Hull, double, triple, or volume-weighted averages. It also adds optional crossover labels, forecast displays, and ribbons between averages.

Entries follow upward crosses and exits can follow downward crosses, with percentage-based profit and loss distances. The strategy declaration includes percentage commission and slippage settings, illustrating how trading costs enter a backtest. The author cautions that calculating on every tick may produce different historical and live behavior, and that nonstandard chart prices can distort simulated fills. The source shows example settings, including a fee rate tied to a specific exchange and date, but supplies no performance report; those costs and parameters should not be treated as current or generally applicable.

Key ideas

  • Three moving averages can be configured by type, source, period, and timeframe.
  • Selected pairwise crossovers generate long entries and opposite crosses close positions.
  • Profit and loss exits use price-relative percentages converted to tick distances.
  • Commission and slippage settings let the strategy account for trading frictions in simulation.
  • Intrabar calculations and nonstandard chart prices can make backtests differ from live execution.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.