The Moving Average Crossover Trend strategy is a trend-following strategy based on moving average crossover signals. It uses the golden cross and death cross of fast and slow moving averages to determine market trends, establishes positions at the beginning of trends, and closes positions when trend reversal signals appear.
The strategy uses the crossovers of MACD histogram and signal line to identify the start and end of trends. Specifically, it constructs the MACD histogram based on 12-period fast EMA and 26-period slow EMA. When the histogram crosses above the signal line, a buy signal is generated, indicating the start of an uptrend. When the histogram crosses below the signal line, a sell signal is triggered, marking the start of a downtrend.
For entries, the strategy only goes long when a buy signal is generated on the 15-min chart to capitalize on the early stage of trend starts. For exits, it closes all positions when the MACD histogram crosses below the signal line on the 4-hour chart, signaling a trend reversal.
The biggest advantage of this strategy is its ability to timely catch trend starts and exit on reversal signals, achieving good risk-reward ratios. The main advantages are:
There are also some risks mainly in the following aspects:
To mitigate the risks, optimizations can be made in:
The main aspects to further optimize the strategy include:
Overall, the Moving Average Crossover Trend Strategy is a simple and practical trend following system. It capitalizes on trends by identifying starts and ends using MACD crossovers, and combining short-term and long-term positions. The advantages lie in its timely entries, effective stops, and balanced risk-reward. Next steps would be improving robustness and profitability via parameterized optimization, signal filtering etc.
/*backtest start: 2024-01-01 00:00:00 end: 2024-01-31 23:59:59 period: 3h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy(title="Moving Average Convergence Divergence", shorttitle="MACD", overlay=true) // Getting inputs fast_length = input(title="Fast Length", defval=12) slow_length = input(title="Slow Length", defval=26) src = input(title="Source", defval=close) signal_length = input.int(title="Signal Smoothing", minval=1, maxval=50, defval=9) sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) // Calculating MACD fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal_line = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) // Entry conditions longCondition = macd < 0 and ta.crossover(macd, signal_line) shortCondition = ta.crossover(signal_line, macd) // Plot signals plotshape(series=longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal") plotshape(series=shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal") // Strategy if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short)