Strategy vault / Trend following
Multi Period Moving Average Trend Following with VWAP Cross Strategy
This strategy is a trend following system that combines multiple period moving averages with Volume Weighted Average Price (VWAP). The strategy identifies trend direction through the crossover of three Simple Moving…

Overview
This strategy is a trend following system that combines multiple period moving averages with Volume Weighted Average Price (VWAP). The strategy identifies trend direction through the crossover of three Simple Moving Averages (SMA) - 9-period, 50-period, and 200-period, while using VWAP as a price strength confirmation indicator, implementing a multi-dimensional trading signal confirmation mechanism. The strategy is suitable for both intraday trading (1-minute chart) and swing trading (1-hour chart).
Strategy Principles
The core logic of the strategy is built on several key elements:
- Using SMA9 and SMA50 crossover to trigger trading signals
- Using SMA200 as a long-term trend filter
- Incorporating VWAP for price strength confirmation
Long entry conditions require:
- SMA9 crosses above SMA50
- SMA200 is below SMA50 (confirming uptrend)
- Closing price is above VWAP (confirming price strength)
Short entry conditions require:
- SMA9 crosses below SMA50
- SMA200 is above SMA50 (confirming downtrend)
- Closing price is below VWAP (confirming price weakness)
Strategy Advantages
- Multiple confirmation mechanism: The triple moving average system combined with VWAP greatly reduces false breakout risks
- High adaptability: The strategy can be used across different timeframes, suitable for various trading styles
- Trend filtering: Using SMA200 as a trend filter avoids frequent trading in ranging markets
- Volume-price integration: Incorporating VWAP achieves organic combination of price and volume
- Simple execution: Strategy logic is clear, easy to understand and implement
- Controlled risk: Clear stop-loss conditions enable timely exit
Strategy Risks
- Lag risk: Moving averages inherently have lag, which may delay entry and exit timing
- Consolidation risk: May generate frequent false signals in ranging markets
- Trend reversal risk: May experience significant drawdowns during rapid trend reversals
- Parameter sensitivity: Optimal parameters may vary across different market conditions
Risk control suggestions:
- Recommend combining other technical indicators for trade confirmation
- Set appropriate stop-loss levels
- Adjust parameters according to different market cycles
- Control position size for each trade
Strategy Optimization Directions
- Dynamic parameter optimization:
- Dynamically adjust moving average periods based on market volatility
- Introduce adaptive parameter mechanisms
- Signal filtering enhancement:
- Add volume confirmation mechanism
- Implement volatility filters
- Incorporate price pattern analysis
- Risk management optimization:
- Implement dynamic position sizing
- Optimize stop-loss and take-profit mechanisms
- Add drawdown control
- Market adaptability enhancement:
- Add market condition identification mechanism
- Apply different parameter settings for different market states
Summary
This is a complete trading system combining multiple period moving averages and VWAP, providing reliable trading signals through multiple confirmation mechanisms. The strategy's strengths lie in its clear logic, ease of execution, and good risk control capabilities. While it has certain risks related to lag and parameter sensitivity, these can be addressed through the suggested optimization directions to further enhance stability and adaptability. The strategy serves as a solid foundation framework that traders can customize according to their trading style and market environment.
Source Pine Script
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-05 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SMA Crossover Strategy with VWAP", overlay=true)
// Input lengths for SMAs
sma9Length = 9
sma50Length = 50
sma200Length = 200
// Calculate SMAs
sma9 = ta.sma(close, sma9Length) // 9-period SMA
sma50 = ta.sma(close, sma50Length) // 50-period SMA
sma200 = ta.sma(close, sma200Length) // 200-period SMA
// Calculate VWAP
vwapValue = ta.vwap(close)
// Long entry condition: SMA 9 crosses above SMA 50 and SMA 200 is less than SMA 50, and close is above VWAP
longCondition = ta.crossover(sma9, sma50) and (sma200 < sma50) and (close > vwapValue)
if (longCondition)
strategy.entry("Long", strategy.long)
// Exit condition for long: SMA 9 crosses below SMA 50
longExitCondition = ta.crossunder(sma9, sma50)
if (longExitCondition)
strategy.close("Long")
// Short entry condition: SMA 9 crosses below SMA 50 and SMA 200 is greater than SMA 50, and close is below VWAP
shortCondition = ta.crossunder(sma9, sma50) and (sma200 > sma50) and (close < vwapValue)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Exit condition for short: SMA 9 crosses above SMA 50
shortExitCondition = ta.crossover(sma9, sma50)
if (shortExitCondition)
strategy.close("Short")
// Plotting the indicators on the chart
plot(sma9, color=color.blue, title="SMA 9")
plot(sma50, color=color.orange, title="SMA 50")
plot(sma200, color=color.red, title="SMA 200")
plot(vwapValue, color=color.green, title="VWAP")Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-06. 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-Trend-Following-with-VWAP-Cross-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
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Trend Following Strategy Based on Moving Average 439858Pine Script · Trend following · 1d
- Multi Timeframe Volume and Trend Confluence Trading StrategyPine Script · Trend following · 1d
- Intelligent Multi Dimensional Adaptive Trend Trading SystemPine Script · Trend following · 1h
- High Frequency Dynamic Multi Indicator Moving Average Crossover StrategyPine Script · Trend following · 1d
- Trend Following Strategy Based on Volume weighted Average Price and VolatilityPine Script · Trend following · 1d