Type/to search

Multiple Moving Averages Crossover Trading Strategy

Cryptocurrency
Created: 2023-12-20 14:12:20
Last modified: 2 years ago
1
Follow
1779
Followers

img

Overview
This strategy is based on the crossover of three moving average lines (MA1, MA2, MA3). By setting the type, period, price data source, resolution of the three MAs, as well as enabling trading on their crosses, flexible trading strategy combinations can be obtained.

Principle
The strategy mainly utilizes the crossover and undercross signals between the three moving average lines as trading signals. When the shorter period MA crosses over the longer period MA from bottom to top, it generates a long entry signal; when the shorter period MA crosses under the longer period MA from top to bottom, it generates an exit signal.

Users can freely choose the type (SMA, EMA, etc), period, price data source (close price, highest price, etc) and resolution (minute bars, daily bars, etc) of the three MAs. Also, trading on the crosses between each MA can be enabled or disabled to determine whether to take trading actions on certain crosses.

Currently the strategy only goes long, entering and exiting positions with market orders. By default each trade utilizes 100% of total account equity.

Advantages

  1. Flexible optimization and combination by freely choosing parameters of MAs, lowering curve fitting risk
  2. Multiple MA crosses generate more trading opportunities, increasing trading frequency
  3. Utilizing long, medium and short term MAs balances between trend following and reversal
  4. Support for different resolutions allows for multi timeframe analysis
  5. Built-in forecast functionality enables test of parameters fitting effect

Risks

  1. Large amount of parameter combinations may lead to overfitting
  2. High trading frequency may increase costs of trading fees and slippage
  3. Market orders unable to limit entry price
  4. Conflicting signals may occur with multiple MAs
  5. Performance difference may exist between backtest and live trading

Optimization Suggestions

  1. Obtain valid parameter range through walks forward analysis
  2. Add trading fees and slippage costs in backtest
  3. Try limit orders instead of market orders
  4. Add filters to avoid conflicting signals
  5. Validate strategy robustness in simulated realistic environment

Summary
The strategy comprehensively leverages the smoothing trait of MAs and pattern recognition power of crossover signals. Users can flexibly choose parameters to balance between trend following and reversal identification. Also the risk of overfitting should be controlled by validating strategy robustness under complex market conditions simulated in backtest. In conclusion, this strategy provides an effective example of utilizing multiple MAs for trading.

Source
Pine
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4 

//
// Pine Script v4
Strategy parameters
Strategy parameters
MA1 Period
MA1 Type
MA1 Source
MA1 Resolution
MA1 Visible
MA2 Period
MA2 Type
MA2 Source
MA2 Resolution
MA2 Visible
MA3 Period
MA3 Type
MA3 Source
MA3 Resolution
MA3 Visible
Show Crosses
Forecast Bias
Forecast Bias Period
Forecast Bias Magnitude
Show Forecasts
Show Ribbons
Trade MA 1-2 Crosses
Trade MA 1-3 Crosses
Trade MA 2-3 Crosses
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)