Type/to search

Dual Moving Average Crossover Strategy

Common strategy
Created: 2024-01-12 14:59:18
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

The Dual Moving Average Crossover strategy is a typical trend following strategy. It uses two EMA lines with different periods and goes long when the shorter period EMA crosses over the longer period EMA and goes short when the opposite crossing happens to capture trend reversals.

Principles

The core indicators of this strategy are two EMA lines, one is 30-period and the other is 60-period. The two EMA lines are calculated by custom functions in the code:

emaLen1 = emaFuncOne(close, lenMA1) emaLen2 = emaFuncTwo(close, lenMA2)

The trading signals are generated from the crossing of the two EMA lines:

currentState = if emaLen2 > emaLen1 0 else 1 previousState = if emaLastLen2 > emaLastLen1 0 else 1 convergence = if currentState != previousState 1 else 0

When the shorter period EMA crosses over the longer period EMA, currentState is not equal to previousState, a crossover signal is triggered, go long.
When the shorter period EMA crosses below the longer period EMA, currentState is not equal to previousState, a crossover signal is triggered, go short.

Advantage Analysis

The advantages of this strategy are:

  1. The logic is simple and intuitive, easy to understand and implement
  2. Smoothes price fluctuations with EMA and filters out market noise
  3. Automatically follows trends, avoids missing trades

Risk Analysis

There are also some risks with this strategy:

  1. Crossover signals may lag and fail to capture reversals in a timely manner
  2. Whipsaw signals may occur frequently during ranging markets
  3. Poor parameter tuning may cause oversensitivity or delays

Optimization can be done by adjusting EMA periods or adding filters.

Optimization Directions

This strategy can be optimized from the following aspects:

  1. Test different EMA period combinations
  2. Add volume or volatility filters to reduce false signals
  3. Incorporate other indicators like MACD to confirm trends
  4. Optimize money management with stop loss and take profit

Conclusion

The Dual Moving Average Crossover strategy is a simple and practical trend following system overall. It is straight-forward, easy to implement and can automatically track trends. But some risks like lagging and false signals exist. With parameter tuning and adding filters, it can be further improved to become one of the fundamental algorithmic trading strategies.

Source
Pine
/*backtest
start: 2024-01-10 00:00:00
end: 2024-01-11 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("ParkerMAStrat", overlay=true)

lenMA1=input(title="Length 1", defval=30)
Strategy parameters
Strategy parameters
Length 1
Length 2
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)