
In short-cycle crypto trading, many traders encounter the same dilemma:
they miss the move when a trend first appears, but once they chase it, a reversal often follows. The root cause is usually not “poor judgment,” but signals that are not reproducible and rules that are not clearly defined.
The value of momentum trading lies in the fact that it can be broken down into explicit conditions + continuous validation, making it highly suitable for systematic and quantitative implementation.
This article uses a dual moving average + RSI framework to demonstrate how a short-term momentum strategy can be transformed into executable logic, with multi-language implementation examples.
1. Quantifying the Strategy Logic
1. Indicator Definitions
- Fast line: MA (e.g., 5-period Simple Moving Average)
- Slow line: EMA (e.g., 20-period Exponential Moving Average)
- RSI: 14-period
2. Necessary Conditions for a Long Momentum Signal
Signals are defined by “all conditions must be met,” not by vague intuition:
- MA > EMA (trend direction)
- Current candle close > MA and > EMA
- RSI ∈ [50, 70] (trend strength, not extreme overbought)
- Signal occurs outside of a consolidation zone (optional filter)
Short conditions are fully symmetrical.
2. Python Example (Backtesting / Rapid Validation)
Suitable for quantitative research, backtesting, and prototyping.
import pandas as pd
import ta
def momentum_signal(df):
df['ma'] = df['close'].rolling(5).mean()
df['ema'] = df['close'].ewm(span=20).mean()
df['rsi'] = ta.momentum.RSIIndicator(df['close'], window=14).rsi()
long_cond = (
(df['ma'] > df['ema']) &
(df['close'] > df['ma']) &
(df['close'] > df['ema']) &
(df['rsi'] >= 50) &
(df['rsi'] <= 70)
)
short_cond = (
(df['ma'] < df['ema']) &
(df['close'] < df['ma']) &
(df['close'] < df['ema']) &
(df['rsi'] >= 30) &
(df['rsi'] <= 50)
)
df['signal'] = 0
df.loc[long_cond, 'signal'] = 1
df.loc[short_cond, 'signal'] = -1
return df
Technical Notes
- Signals are discrete (
-1 / 0 / 1), which simplifies backtesting and statistics - RSI avoids extreme values to reduce false triggers in ranging markets
- Can be directly applied to minute-level historical data with rolling-window backtests
3. Java Example (Real-Time Strategy / Trading System)
Suitable for matching engines, risk-control systems, or real-time signal modules.
public boolean isLongSignal(
double close,
double ma,
double ema,
double rsi
) {
return ma > ema
&& close > ma
&& close > ema
&& rsi >= 50.0
&& rsi <= 70.0;
}
public boolean isShortSignal(
double close,
double ma,
double ema,
double rsi
) {
return ma < ema
&& close < ma
&& close < ema
&& rsi >= 30.0
&& rsi <= 50.0;
}
Engineering Practice Suggestions
- Calculate moving averages and RSI in a dedicated indicator module
- The Signal module should only handle condition evaluation
- Can be directly fed by WebSocket market data, updating on each completed candle
4. C++ Example (Low-Latency / High-Performance Environments)
Suitable for performance-critical market data processing or strategy modules.
struct Bar {
double close;
double ma;
double ema;
double rsi;
};
bool longSignal(const Bar& b) {
return b.ma > b.ema &&
b.close > b.ma &&
b.close > b.ema &&
b.rsi >= 50.0 &&
b.rsi <= 70.0;
}
bool shortSignal(const Bar& b) {
return b.ma < b.ema &&
b.close < b.ma &&
b.close < b.ema &&
b.rsi >= 30.0 &&
b.rsi <= 50.0;
}
Typical Use Cases
- Market data → indicators → signals → downstream execution
- Cleanly decoupled from matching and risk-control modules
- Well suited for use as a strategy factor layer
5. Programmatic Expression of Risk Control
Many strategies fail not because the entry signal is wrong, but because exit rules are not strictly defined.
Common approaches include:
- Long stop-loss: EMA of the most recent confirmation candle
- Fixed risk–reward ratio, e.g. 1:1.5 or 1:2
- Risk per trade ≤ 1%–2% of total account equity
All of these rules can be fully programmatic rather than relying on discretionary judgment.
6. Why Momentum Strategies Are Well Suited for Systematic Trading
- Clear, reproducible conditions
- No reliance on subjective judgment
- Easy to measure win rate and expected value
- Quick to validate across different instruments and timeframes
In live or simulated trading, combined with stable real-time market data and historical datasets, you can rapidly perform:
- Signal replay
- Parameter tuning
- Performance comparison across different market regimes


