This strategy is a high-frequency quantitative trading system that combines momentum trading and mean reversion approaches. Operating on a 5-minute timeframe, it captures trending opportunities using Exponential Moving Averages (EMA) while identifying overbought and oversold conditions through Bollinger Bands. The strategy features flexible parameter configuration, allowing for single or combined trading modes based on market conditions.
The strategy employs a dual-layer trading logic:
The strategy combines momentum and mean reversion methods to create a highly adaptable, risk-controlled high-frequency quantitative trading system. Its modular design and parameter flexibility provide practical value, and with continuous optimization and risk management improvements, it shows promise for generating stable returns in live trading.
/*backtest start: 2024-12-06 00:00:00 end: 2025-01-04 08:00:00 period: 1h basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Momentum and Mean Reversion Strategy", shorttitle = "MMV_V1", overlay=true) // --- Inputit ja parametrit --- use_momentum = input.bool(true, title="Käytä Momentum-strategiaa") use_mean_reversion = input.bool(true, title="Käytä Keskiarvoon Palautumista (BB)") // Momentum-parametrit short_ema_period = input.int(50, title="Lyhyt EMA") long_ema_period = input.int(400, title="Pitkä EMA") // Bollinger Band -parametrit bb_length = input.int(20, title="BB Pituus") bb_std = input.float(2.0, title="BB Standardipoikkeama") // --- Momentum-strategia: EMA-risteämä --- short_ema = ta.ema(close, short_ema_period) long_ema = ta.ema(close, long_ema_period) momentum_long_signal = ta.crossover(short_ema, long_ema) momentum_short_signal = ta.crossunder(short_ema, long_ema) // --- Keskiarvoon palautuminen: Bollinger Bands --- [bb_upper, bb_middle, bb_lower] = ta.bb(close, bb_length, bb_std) bb_long_signal = ta.crossover(close, bb_lower) // Osto, kun hinta nousee alemman BB:n yli bb_short_signal = ta.crossunder(close, bb_upper) // Myynti, kun hinta laskee ylemmän BB:n ali // --- Kaupankäyntilogiikka --- if (use_momentum and momentum_long_signal) strategy.entry("Momentum Long", strategy.long) if (use_momentum and momentum_short_signal) strategy.entry("Momentum Short", strategy.short) if (use_mean_reversion and bb_long_signal) strategy.entry("BB Long", strategy.long) if (use_mean_reversion and bb_short_signal) strategy.entry("BB Short", strategy.short)