Strategy vault / Trend following
Multi Period Moving Average Crossover with Volume Analysis System
This is a quantitative trading strategy system based on moving average crossover and volume analysis. The strategy makes trading decisions through crossover signals of various types of moving averages (including EMA…

Overview
This is a quantitative trading strategy system based on moving average crossover and volume analysis. The strategy makes trading decisions through crossover signals of various types of moving averages (including EMA, SMA, and WMA), combined with volume indicators. The system supports flexible configuration of moving average types and parameters, while introducing volume analysis as a trade confirmation condition to improve reliability.
Strategy Principles
The strategy uses a dual moving average crossover system as the core trading signal, combined with volume analysis as auxiliary judgment:
- Uses two moving averages (MA1 and MA2) of different periods, supporting free switching between SMA, EMA, and WMA.
- Introduces Volume SMA as a volume reference standard.
- Uses 200-period EMA as a long-term trend judgment benchmark.
- Generates long signals when the fast MA crosses above the slow MA with volume above its average.
- Generates short signals when the fast MA crosses below the slow MA with volume above its average.
Strategy Advantages
- High Flexibility: Supports multiple MA types to meet different trading style needs.
- Reliable Signals: Improves signal quality through volume confirmation.
- Trend Following: Incorporates long-period EMA to avoid counter-trend trading.
- Adjustable Parameters: MA periods and volume periods can be flexibly adjusted.
- Systematic Operation: Clear trading rules, minimizing subjective factors.
Strategy Risks
- Consolidation Risk: May generate frequent false breakout signals in sideways markets.
- Lag Risk: Moving averages have inherent lag, potentially missing optimal entry points.
- Cost Risk: Frequent trading may lead to high transaction costs.
- Market Environment Dependence: Strategy effectiveness heavily relies on trend strength.
Optimization Directions
- Add Trend Strength Indicators: Consider adding ADX for trading only in strong trends.
- Optimize Stop Loss: Implement trailing or fixed stop loss for risk control.
- Enhance Market Cycle Analysis: Incorporate volatility indicators for parameter adaptation.
- Improve Volume Analysis: Add volume pattern recognition for better signal quality.
- Implement Risk Control: Set maximum position limits and daily stop loss limits.
Summary
This is a quantitative trading strategy combining classical technical analysis theories through moving average crossover and volume analysis. The strategy design is reasonable with strong practicality and scalability. Through parameter optimization and module enhancement, the strategy's stability and profitability can be further improved. It's recommended to conduct thorough backtesting before live trading and adjust parameters according to specific trading instrument characteristics.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Cruzamento de Médias com Volume ☾︎ ???? ✞︎ ?????? ☽︎", overlay=true)
// Criação de opções no editor para selecionar o tipo de média móvel
maType1 = input.string(title="Tipo de Média Móvel 1", defval="EMA", options=["SMA", "EMA", "WMA"])
maType2 = input.string(title="Tipo de Média Móvel 2", defval="EMA", options=["SMA", "EMA", "WMA"])
// Função para selecionar a média móvel de acordo com o tipo escolhido
getMovingAverage(maType, src, length) =>
if maType == "SMA"
ta.sma(src, length)
else if maType == "EMA"
ta.ema(src, length)
else if maType == "WMA"
ta.wma(src, length)
else
na
// Parâmetros para o cálculo das médias móveis
length1 = input.int(9, title="Período da Média 1")
length2 = input.int(21, title="Período da Média 2")
// Cálculo das médias móveis escolhidas
ma1 = getMovingAverage(maType1, close, length1)
ma2 = getMovingAverage(maType2, close, length2)
// Parâmetro editável para o período da média de volume
volLength = input.int(20, title="Período da Média de Volume")
// Cálculo da média móvel do volume com período ajustável
volSMA = ta.sma(volume, volLength) // Média móvel simples do volume
// Cálculo da EMA de 200 períodos para visualizar a tendência primária
ema200 = ta.ema(close, 200)
// Condições para compra: ma1 cruza acima da ma2 + Volume acima da média de volume ajustável
longCondition = ta.crossover(ma1, ma2) and volume > volSMA
// Condições para venda: ma1 cruza abaixo da ma2 + Volume acima da média de volume ajustável
shortCondition = ta.crossunder(ma1, ma2) and volume > volSMA
// Executa a operação de compra
if (longCondition)
strategy.entry("Compra", strategy.long)
// Executa a operação de venda
if (shortCondition)
strategy.entry("Venda", strategy.short)
// Plotando as médias móveis no gráfico de preços
plot(ma1, color=color.green, title="Média Móvel 1", linewidth=2)
plot(ma2, color=color.red, title="Média Móvel 2", linewidth=2)
// Plotando a EMA de 200 períodos para visualização da tendência de longo prazo
plot(ema200, color=color.orange, title="EMA 200", linewidth=2)
// Plotando a média de volume para visualização no painel inferior
plot(volSMA, color=color.blue, title="Média de Volume", linewidth=2)Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-27. 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/Multi-Period-Moving-Average-Crossover-with-Volume-Analysis-System.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
- Multi Factor Trend Price Action Strategy with Dynamic Risk Management SystemPine Script · Trend following · 2h
- DPO EMA Trend Crossover Quantitative Strategy ResearchPine Script · Trend following · 1d
- Dual EMA Crossover Trend Following Strategy with ATR and ADX FiltersPine Script · Trend following · 1d
- Advanced Multi Indicator Trend Confirmation Trading StrategyPine Script · Trend following · 1d
- Advanced Quantitative Trading Multi Moving Average Crossover System with Volume Filter StrategyPine Script · Trend following · 1d
- Low Timeframe High Leverage Trend Following Trading StrategyPine Script · Trend following · 1h