Strategy vault / Mean reversion
Momentum Reversal Strategy
This strategy calculates the momentum indicator of price to determine whether the price trend has reversed, in order to capture price reversal opportunities. When the uptrend or downtrend of the price slows down, it…

Overview
This strategy calculates the momentum indicator of price to determine whether the price trend has reversed, in order to capture price reversal opportunities. When the uptrend or downtrend of the price slows down, it indicates that the price momentum has reversed. At this time, the strategy will open long or short positions.
Strategy Logic
The strategy is mainly based on the calculation of momentum indicators. The momentum indicator reflects the speed and strength of price changes. Two momentum indicators MOM and MOM1 are calculated in the strategy.
MOM calculation formula:
MOM = Today's closing price - Closing price N days ago
MOM1 calculation formula:
MOM1 = MOM today - MOM yesterday
Judge whether prices have reversed according to the values of MOM and MOM1. If MOM > 0 and MOM1 < 0, it means the uptrend of the price has slowed down and a reversal signal appears to go long. If MOM < 0 and MOM1 > 0, it means the downtrend of the price has slowed down and a reversal signal appears to go short.
Advantages
- Capture price reversal points and enter the market in time
- Small drawdowns, avoid chasing highs and selling lows
- Implement automatic stop loss to reduce risks
Risks
- Frequent opening and closing of positions may occur when prices fluctuate
- Inability to accurately determine price reversal points if parameters are set improperly
- Market events may cause incorrect signals
Main risk mitigation methods:
- Optimize parameters to improve judgment accuracy
- Combine with other indicators to filter signals
- Manual intervention to avoid losses caused by abnormal markets
Optimization Directions
- Optimize momentum indicator parameters to better capture timing of reversals
- Add indicators like volume to filter incorrect signals
- Add stop loss strategies to reduce single loss
Summary
This strategy calculates the price momentum indicator to determine whether the price trend has reversed, automatically going long or short. Backtests show that this strategy works smoothly overall and effectively captures price reversal points. By optimizing parameter settings, adding signal filters, etc., the stability and profitability of the strategy can be further improved.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 12 | Length |
| v_input_2_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_3 | true | Percent? |
| v_input_4 | 0 | MOM Choice: MOM2 | MOM1 |
Source Pine Script
/*backtest
start: 2023-11-11 00:00:00
end: 2023-12-11 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Momentum - Strategy", overlay = false, precision = 2, initial_capital = 10000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_type = strategy.commission.percent, commission_value = 0.2 )
i_len = input(defval = 12, title = "Length", minval = 1)
i_src = input(defval = close, title = "Source")
i_percent = input(defval = true, title = "Percent?")
i_mom = input(defval = "MOM2", title = "MOM Choice", options = ["MOM1", "MOM2"])
momentum(seria, length, percent) =>
_mom = percent ? ( (seria / seria[length]) - 1) * 100 : seria - seria[length]
_mom
mom0 = momentum(i_src, i_len, i_percent)
mom1 = momentum(mom0, 1, i_percent)
mom2 = momentum(i_src, 1, i_percent)
momX = mom1
if i_mom == "MOM2"
momX := mom2
if (mom0 > 0 and momX > 0)
strategy.entry("MomLE", strategy.long, stop = high + syminfo.mintick, comment = "MomLE")
else
strategy.cancel("MomLE")
if (mom0 < 0 and momX < 0)
strategy.entry("MomSE", strategy.short, stop = low - syminfo.mintick, comment = "MomSE")
else
strategy.cancel("MomSE")
plot(mom0, color = #0000FF, title = "MOM")
plot(mom1, color = #00FF00, title = "MOM1", display = display.none)
plot(mom2, color = #00FF00, title = "MOM2")Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-12. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Momentum-Reversal-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- A Trend Reversal Strategy Based on Moving Averages Price Patterns and VolumePine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Adaptive Mean Reversion Trading Strategy Based on Chande Momentum OscillatorPine Script · Mean reversion · 1d
- Adaptive Moving Average Tracking StrategyPine Script · Mean reversion · 1d