- Square
- Multi Timeframe Moving Average Trading Strategy
Author: ChaoZhang, Date: 2023-09-21 20:45:38
Tags:
Overview
This strategy uses moving average crossovers between different timeframes to generate trading signals. It allows observing longer timeframe MAs on current chart to detect larger trends. This belongs to inter-timeframe trend following strategies.
Strategy Logic
The strategy uses two moving averages calculated on separate timeframes.
For example on 15min chart it uses 20MA and 50MA:
- 20MA is calculated on current 15min bars
- 50MA is calculated on daily bars
When 15min 20MA crosses above daily 50MA, it goes long. When 15min 20MA crosses below daily 50MA, it goes short.
This achieves the effect of observing longer timeframe trends on current period. Custom MA lengths are also allowed.
Crossover points can be marked for clear trade signals.
Advantages
- Analyze across timeframes, discover larger trends
- Higher TF lines more stable, avoiding false signals
- Lower TF lines more sensitive, catching trend changes fast
- Customizable MA periods combinations
- Clear marked signals on chart
Risks
- Increased complexity with multiple timeframes
- Lower TF false signals still possible
- Overall lagging with MA systems, may miss best entries
- Limited filtering with pure MA system
- Period tuning needed for different products
Risks can be reduced by:
- Keeping longer high TF MAs for robust trend direction
- Adding other indicators for further signal filtering
- Optimizing MA periods for best combinations
- Relaxing entry rules like adding candlestick patterns
Enhancement Directions
The strategy can be improved by:
Testing more MA period combinations for optimization
Adding secondary confirmation when crossover happens
e.g. check MACD momentum
Optimizing stops to avoid premature exit
Consider Post123 evidence to decide exits
Different filters for short and long TF
More strict for short TF, more relaxed for long TF
Consider different parameter sets for different sessions
Market conditions vary by sessions
Summary
This strategy observes crossovers between MAs of multiple timeframes to determine trend direction and uncover larger trends. This filters out short-term noises and focuses on larger price moves. However, challenges like timeframe tuning and lagging signals exist. Enhancements can be made via rigorous backtesting and optimization for robust parameters, adding filters for confirmation, live validation for continuous improvements according to market feedback. Persistent learning and optimization is key to adaptivity.
/*backteststart: 2022-09-14 00:00:00end: 2023-09-20 00:00:00period: 7dbasePeriod: 1dexchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]*///@version=2//Run script on a long interval gives better result for e.g. 1 Day//Plots The Majority of Moving Averages//Defaults to Current Chart Time Frame --- But Can Be Changed to Higher Or Lower Time Frames//2nd MA Capability with Show Crosses Feature//study(title="CM_Ultimate_MA_MTF", shorttitle="CM_Ultimate_MA_MTF", overlay=true)strategy("Stratergy CM_Ultimate_MA_MTF", shorttitle = "Stratergy CM_Ultimate_MA_MTF", overlay = true) //,default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)//inputssrc = closeuseCurrentRes = input(true, title="Use Current Chart Resolution?")resCustom = input(title="Use Different Timeframe? Uncheck Box Above", defval="D")len = input(20, title="Moving Average Length - LookBack Period")atype = input(1,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA")cc = input(true,title="Change Color Based On Direction?")smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - 1 = No Smoothing")doma2 = input(false, title="Optional 2nd Moving Average")len2 = input(50, title="Moving Average Length - Optional 2nd MA")atype2 = input(1,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA")cc2 = input(true,title="Change Color Based On Direction 2nd MA?")warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***")warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***")sd = input(false, title="Show Dots on Cross of Both MA's")res = useCurrentRes ? timeframe.period : resCustom//hull ma definitionhullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len)))//TEMA definitionema1 = ema(src, len)ema2 = ema(ema1, len)ema3 = ema(ema2, len)tema = 3 * (ema1 - ema2) + ema3avg = atype == 1 ? sma(src,len) : atype == 2 ? ema(src,len) : atype == 3 ? wma(src,len) : atype == 4 ? hullma : atype == 5 ? vwma(src, len) : atype == 6 ? rma(src,len) : tema//2nd Ma - hull ma definitionhullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2)))//2nd MA TEMA definitionsema1 = ema(src, len2)sema2 = ema(sema1, len2)sema3 = ema(sema2, len2)stema = 3 * (sema1 - sema2) + sema3avg2 = atype2 == 1 ? sma(src,len2) : atype2 == 2 ? ema(src,len2) : atype2 == 3 ? wma(src,len2) : atype2 == 4 ? hullma2 : atype2 == 5 ? vwma(src, len2) : atype2 == 6 ? rma(src,len2) : temaout = avg out_two = avg2out1 = security(syminfo.tickerid, res, out)out2 = security(syminfo.tickerid, res, out_two)ma_up = out1 >= out1[smoothe]ma_down = out1 < out1[smoothe]col = cc ? ma_up ? lime : ma_down ? red : aqua : aquacol2 = cc2 ? ma_up ? lime : ma_down ? red : aqua : aquacircleYPosition = out2chk=col==red?1:0if (not na(chk)) if (chk[1]==1 and chk==0) strategy.entry("RsiLE", strategy.long, comment="RsiLE") else strategy.exit("RsiLE") if (chk[1]==0 and chk==1) strategy.entry("RsiSE", strategy.short, comment="RsiLE") else strategy.exit("RsiSE") plot(out1, title="Multi-Timeframe Moving Avg", style=line, linewidth=4, color = col)plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=circles, linewidth=4, color=col2)plot(sd and cross(out1, out2) ? circleYPosition : na,style=cross, linewidth=5, color=yellow)
More
- Trend Following Strategy Based on Volume-weighted Average Price and Volatility
- Momentum Moving Average Crossover Strategy
- Range Filter Breakout Short-term Trading Strategy
- Smart Money Index (SMI) Strategy Backtest
- Quantitative Reversal and Volume Combo Strategy
- Bollinger Bands and Fibonacci Trading Strategy
- Bollinger Band and Stoch RSI Trading Strategy
- Best Trailing Stop Strategy
- RSI Long Term Trading Strategy
- MACD of RSI Trading Strategy
- Moving Average Scalping Strategy
- Volatility Range Breakout Trading Strategy
- Trend Moving Average Trading Strategy
- Multi Trend Crossover Strategy
- Dual Moving Average Crossover Strategy
- Price Performance Index Strategy
- MACD RSI Combo Trend Strategy
- Logarithmic Moving Average Convergence Divergence Strategy
- Absolute Price Oscillator Trend Following Strategy
- Round Number Tracking Strategy