The resource loading... loading...

Momentum Moving Average Crossover Trading Strategy

Author: ChaoZhang, Date: 2024-02-19 14:53:50
Tags:

img

Overview

This strategy generates trading signals based on the MACD indicator. The MACD indicator consists of three lines: the MACD line, SIGNAL line and histogram (HISTO) line. When the MACD line crosses above the SIGNAL line and turns positive, it generates a buy signal. When the MACD line crosses below the SIGNAL line and turns negative, it generates a sell signal.

Strategy Logic

  1. Calculate the MACD line, SIGNAL line and HISTO line.
  2. Identify crossover points between the MACD line and SIGNAL line to determine buy and sell signals.
  3. Use a 34-period EMA as support/resistance zone, go long only above EMA and go short only below EMA.
  4. Set stop loss and take profit to lock in profits.

Specifically, when the close price crosses above the 34-period EMA and the MACD line crosses above the SIGNAL line into positive territory, it indicates strong upside momentum, so we buy. When the close price crosses below the 34-period EMA and the MACD line crosses below the SIGNAL line into negative territory, it indicates strong downside momentum, so we sell.

Advantages

  1. MACD indicator accurately identifies turns in price action with clear signals.
  2. Combining with EMA filter avoids false buy/sell signals.
  3. Stop loss and take profit controls per trade loss.

Risks and Solutions

  1. MACD signals lag price action and may miss best entry/exit points. Can optimize parameters to shorten moving average periods.
  2. Single indicator prone to generating false signals. Can add other indicators like KDJ for filtration.
  3. No limit on number of trades, may lead to overtrading. Can set daily/weekly trade limits.

Enhancement Opportunities

  1. Optimize MACD parameters to find best parameter combination.
  2. Add other indicator judgments to avoid false signals, e.g. MACD+KDJ, MACD+BOLL combinations.
  3. Implement trade frequency limits to prevent overtrading.
  4. Optimize stop loss/take profit strategy to improve risk/reward ratio.

Conclusion

This strategy identifies trading opportunities using the MACD indicator and filters signals using a 34-period EMA. It allows timely entries when new price trends start while controlling risk via stop loss/take profit. The strategy can be further refined via parameter optimization, adding other indicators etc. to improve profitability.


/*backtest
start: 2024-01-19 00:00:00
end: 2024-02-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © melihtuna

//@version=2
strategy("Jim's MACD", overlay=true)

Tendies = input(true, title="Check here for tendies")

// === MACD Setup ===
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)

//EMA
ma = ema(close, 5)
plot(ema(close,5))


//Entry
if (close > ma and cross(macdLine,signalLine) and histLine> 0.4 and signalLine > 0 or histLine > 0 and signalLine > 0 )
    strategy.entry("BUY", strategy.long)
if(close < ma and cross(macdLine,signalLine) and histLine < -0.4 and signalLine < 0 or close < ma and histLine < 0 and signalLine < 0 )
    strategy.entry("SELL", strategy.short)
    
//Exit 
strategy.close("BUY", when = histLine < 0  )
strategy.close("SELL", when = histLine > 0  )


More