Momentum Trend Optimization Combination Strategy

Author: ChaoZhang, Date: 2024-02-06 15:11:57
Tags:

img

Overview

The Momentum Trend Optimization Combination Strategy is a medium- to long-term quantitative trading strategy that combines momentum and trend factors. It generates buy and sell signals by using a combination of exponential moving averages, moving averages, volume and slope indicators. The strategy is optimized for T+1 trading and is only suitable for long positions. The optimizations are also applicable to international stock markets.

Strategy Logic

The strategy uses a 6-day simple moving average and a 35-day simple moving average to define two moving averages. The buy signal line is defined as a 2-day exponential moving average, and the sell signal line is calculated based on the slope over the past 8 closing prices. In addition, a 20-day exponential moving average of volume is defined as the volume indicator. To filter out some noise, the strategy also introduces weekly slope judgment for market direction.

When the closing price is higher than the 35-day moving average, the trading volume is higher than the 20-day average trading volume, and the weekly check shows a bull market, a golden cross from the bottom triggers a buy signal. Conversely, a death cross from the top triggers a sell signal.

For risk management, the strategy introduces a dynamic position adjustment mechanism. The actual position is calculated based on account equity, maximum position ratio, ATR and risk factor. This helps to control the maximum drawdown of the strategy.

Advantage Analysis

The strategy combines momentum factors and trend filtering, which can effectively identify medium- to long-term directions. At the same time, the filtering of noise is also in place to avoid false signals in volatile markets. In addition, the introduction of risk management mechanisms also enables proper control over maximum drawdowns, thus ensuring the robustness of the strategy.

From the backtest results, the overall return of the strategy reached 128.86%, with a very significant Alpha. At the same time, the win rate of the strategy also reached 60.66%, reflecting the stability of the strategy effect.

Risk Analysis

Although the strategy itself has been optimized for risk management mechanisms, there are still some risks that need attention. Specifically, the main risks include:

  1. Drawdown risk. From the single largest loss of 222,021.46 yuan, it can be seen that the retracement amplitude of the strategy is large. This is related to the imperfect position management mechanism.

  2. Signal stability risk. The strategy signal may be affected by special factors of individual stocks, resulting in false signal situations. This will have a certain impact on the strategy’s returns.

  3. Market environment change risk. If the macro market environment changes significantly, the strategy parameters may need to be adjusted in order to continue to maintain the effect.

Optimization Directions

According to the above risk analysis, there is still necessity and possibility to optimize this strategy.

  1. Judging from the maximum loss, the position management mechanism can be further optimized by introducing a stop loss module to control the magnitude of single losses.

  2. Consider adding more filtering indicators to identify some special stock phenomena and reduce the probability of false signals. For example, introduce volume-price divergence indicators.

  3. Continue backtesting and verifying strategy parameters, and make timely parameter adjustments based on changes in market conditions. At the same time, over-optimization should be prevented.

Summary

The Momentum Trend Optimization Combination Strategy is a medium- to long-term quantitative trading strategy that combines momentum factors and trend filtering and is specially optimized for T+1 trading. Judging from the backtest indicators, the overall effect of the strategy is significant, with a very amazing Alpha. But the potential risks should also be concerned about, and parameters should be adjusted in time according to changes in market conditions. The strategy can bring additional Alpha to quantitative traders and is worth further research and verification.


/*backtest
start: 2024-01-06 00:00:00
end: 2024-02-05 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/
// © fzj20020403

////@version=5
//@version=5
strategy("Optimized Zhaocaijinbao", overlay=true, margin_long=100, margin_short=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// Define two moving averages
ma6 = ta.sma(close, 6)
ma35 = ta.sma(close, 35)

// Define buy and sell signal lines
buyLine = ta.ema(close, 2)
sellSlope = (close - close[8]) / 8
sellLine = sellSlope * 1 + ta.sma(close, 8)

// Define volume indicator
volumeEMA = ta.ema(volume, 20)

// Define weekly slope factor
weeklyMa = ta.sma(close, 50)
weeklySlope = (weeklyMa - weeklyMa[4]) / 4 > 0

// Generate buy and sell signals
buySignal = ta.crossover(buyLine, sellLine) and close > ma35 and volume > volumeEMA and weeklySlope
sellSignal = ta.crossunder(sellLine, buyLine)

// Define dynamic position sizing factor
equity = strategy.equity
maxPositionSize = equity * input.float(title='Max Position Size (%)', defval=0.01, minval=0.001, maxval=0.5, step=0.001)
riskFactor = input.float(title='Risk Factor', defval=2.0, minval=0.1, maxval=10.0, step=0.1)
atr = ta.atr(14)
positionSize = maxPositionSize * riskFactor / atr

// Define position status
var inPosition = false

// Define buy and sell conditions
buyCondition = buySignal and not inPosition
sellCondition = sellSignal and inPosition

// Perform buy and sell operations
if (buyCondition)
    strategy.entry("Long", strategy.long, qty=positionSize)
    inPosition := true
if (sellCondition)
    strategy.close("Long")
    inPosition := false

// Draw vertical line markers for buy and sell signals
plotshape(buyCondition, style=shape.arrowdown, location=location.belowbar, color=color.green, size=size.small)
plotshape(sellCondition, style=shape.arrowup, location=location.abovebar, color=color.red, size=size.small)

// Draw two moving averages
plot(ma6, color=color.blue)
plot(ma35, color=color.orange)

// Draw volume indicator line
plot(volumeEMA, color=color.yellow)

// Define stop loss and take profit
stopLoss = strategy.position_avg_price * 0.5
takeProfit = strategy.position_avg_price * 1.25

if inPosition
    strategy.exit("Long Stop Loss", "Long", stop=stopLoss)
    strategy.exit("Long Take Profit", "Long", limit=takeProfit)



More