Strategy vault / Trend following
Fast and Slow Moving Average Crossover Strategy
The fast and slow moving average crossover strategy is a quantitative trading strategy that generates trading signals by comparing fast and slow moving averages. It goes long when the fast MA crosses above the slow…
Strategy Overview
The fast and slow moving average crossover strategy is a quantitative trading strategy that generates trading signals by comparing fast and slow moving averages. It goes long when the fast MA crosses above the slow MA, and goes short when the fast MA crosses below the slow MA. The strategy aims to capture trend turning points on the medium-short term timeframe.
Strategy Logic
Calculate the fast MA, typically 5-10 period EMA.
Calculate the slow MA, typically 20-60 period SMA.
Go long when fast MA crosses above slow MA.
Go short when fast MA crosses below slow MA.
Initiate new trades at each crossover.
The fast MA reacts swiftly to price changes and reflects the latest trend. The slow MA filters out low frequency noises and captures the major trend. Crossovers signal potential trend reversals for improved trading accuracy.
The flexible parameter settings can be optimized for different periods and market environments.
Advantages of the Strategy
Fast and slow MAs combine for trend identification
Clear and simple crossover signals
Period optimization for different markets
Easy to program and backtest
Combinable with other indicators
Risk Warnings
Potential lagging of moving averages
Possible false breakout signals
Prevent excessive trading frequency
Entry and exit levels unclear
Conclusion
The fast and slow MA crossover strategy judges trend turning points by comparing different MA periods, and is a classical and common quantitative trading approach. Parameters can be tuned and combined with other indicators to control risks and improve returns.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 9 | fastLength |
| v_input_2 | 40 | slowlength |
Source Pine Script
/*backtest
start: 2023-08-15 00:00:00
end: 2023-09-14 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Cruzameto 2MM", overlay=true)
fastLength = input(9)
slowlength = input(40)
//MACDLength = input(9)
delta = ema(close, fastLength) - sma(close, slowlength)
//aMACD = ema(MACD, MACDLength)
//delta = MACD - aMACD
if (crossover(delta, 0))
strategy.entry("Compra", strategy.long, comment="2MM")
if (crossunder(delta, 0))
strategy.entry("Venda", strategy.short, comment="2MM")
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-01. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Fast-and-Slow-Moving-Average-Crossover-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual MA Crossover Trend Tracking StrategyPine Script · Trend following · 1h
- Dynamic Dual EMA Crossover Strategy with Adaptive Profit Loss ControlPine Script · Trend following · 1d
- EMA SMA Multi Indicator Comprehensive Trend Following StrategyPine Script · Trend following · 1h
- EMA and RSI Trend Trading StrategyPine Script · Trend following · 1d