Bitcoin Momentum Trading Strategy

Table of Contents

  • 1. Basic Concepts of Momentum Trading
  • 2. 3 Key Elements of the Strategy
  • 3. Core Logic Implementation (Python)
  • 3-1. Install Required Libraries
  • 3-2. Real-Time Data Collection (Based on Binance)
  • 3-3. Technical Indicator Calculation
  • 3-4. Trading Signal Generation Logic
  • 4. Risk Management System
  • 4-1. Position Sizing
  • 4-2. Dynamic Stop Loss
  • 4-3. Trailing Stop
  • 5. Backtesting Example
  • 6. Key Considerations
  • 7. Optimization Points
  • 8. Precautions
This post is part of the Coupang Partners Program and may contain affiliate links, for which I may receive a commission.

Bitcoin Momentum Trading Strategy

KissCuseMe
2025-03-03
3

1. Basic Concepts of Momentum Trading

  • Definition: A strategy that measures the strength of a trend and buys during an upward trend and sells during a downward trend.
  • Key Principle: "The trend is your friend" - Assuming that the existing flow will continue.


2. 3 Key Elements of the Strategy

  1. Momentum Indicators: RSI, MACD, Stochastic
  2. Trend Confirmation: Moving Average (MA), Bollinger Bands
  3. Trading Volume Analysis: OBV (On-Balance Volume), MFI (Money Flow Index)


3. Core Logic Implementation (Python)


3-1. Install Required Libraries

pip install ccxt pandas numpy TA-Lib python-dotenv

3-2. Real-Time Data Collection (Based on Binance)

import ccxt
import pandas as pd

binance = ccxt.binance({
    'apiKey': 'YOUR_API_KEY',
    'secret': 'YOUR_SECRET',
    'enableRateLimit': True
})

<br/>

# Query 1-hour bar data
ohlcv = binance.fetch_ohlcv('BTC/USDT', '1h')
df = pd.DataFrame(ohlcv, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')


3-3. Technical Indicator Calculation

import talib

<br/>

# RSI (14 period)
df['RSI'] = talib.RSI(df['close'], timeperiod=14)

<br/>

# MACD (12,26,9)
df['MACD'], df['MACD_signal'], _ = talib.MACD(df['close'], 
                                            fastperiod=12, 
                                            slowperiod=26, 
                                            signalperiod=9)

<br/>

# 50-day & 200-day moving average
df['MA50'] = talib.SMA(df['close'], timeperiod=50)
df['MA200'] = talib.SMA(df['close'], timeperiod=200)

<br/>

# Bollinger Bands (20 days)
df['upper_band'], df['middle_band'], df['lower_band'] = talib.BBANDS(df['close'], 
                                                                    timeperiod=20)


3-4. Trading Signal Generation Logic

def generate_signal(row):
    # Upward momentum conditions
    bull_condition = (
        (row['RSI'] > 50) &
        (row['MACD'] > row['MACD_signal']) &
        (row['close'] > row['MA200']) &
        (row['close'] > row['upper_band'])
    
    # Downward momentum conditions
    bear_condition = (
        (row['RSI'] < 45) &
        (row['MACD'] < row['MACD_signal']) &
        (row['close'] < row['MA200']) &
        (row['close'] < row['lower_band'])
    
    if bull_condition:
        return 'BUY'
    elif bear_condition:
        return 'SELL'
    else:
        return 'HOLD'

df['signal'] = df.apply(generate_signal, axis=1)


4. Risk Management System


4-1. Position Sizing

def calculate_position_size(balance, risk_percent=2, stop_loss_pct=5):
    max_risk = balance * (risk_percent/100)
    return max_risk / (stop_loss_pct/100)


4-2. Dynamic Stop Loss

def dynamic_stoploss(current_price, atr, multiplier=2):
    return current_price - (atr * multiplier)


4-3. Trailing Stop

def update_trailing_stop(high_price, trail_percent=3):
    return high_price * (1 - (trail_percent/100))


5. Backtesting Example

initial_balance = 10000  # USDT
position = 0
balance = initial_balance
trailing_stop = None

for idx, row in df.iterrows():
    current_price = row['close']
    
    if row['signal'] == 'BUY' and position == 0:
        position = balance / current_price
        balance = 0
        trailing_stop = current_price * 0.97  # 3% initial stop loss
    elif row['signal'] == 'SELL' or current_price < trailing_stop:
        if position > 0:
            balance = position * current_price
            position = 0
            trailing_stop = None
    elif position > 0:
        # Trailing stop update
        trailing_stop = max(trailing_stop, current_price * 0.97)

final_balance = balance + (position * df.iloc[-1]['close'])
print(f"Final rate of return: {((final_balance/initial_balance)-1)*100:.2f}%")


6. Key Considerations

  1. Volatility Management: Need to respond to slippage in the event of gap ups/downs.
  2. Transaction Costs: Reflect fees (recommended below 0.1%) and slippage.
  3. Time Zone Selection:
    • Short-term: 15 minutes to 4-hour candlestick charts
    • Mid- to Long-term: Daily to Weekly candlestick charts
  4. Black Swan Prevention: Essential to check major news event calendar


7. Optimization Points

  • Parameter Tuning: Adjust moving average period and RSI threshold.
  • Multi-Timeframe Analysis: Combine with higher timeframe trends.
  • Machine Learning Integration: Predict momentum acceleration with LSTM


8. Precautions

❗ Avoid Overfitting: Need to verify with data for more than 3 years

❗ Check Liquidity: Avoid sections with less than 100 BTC trading volume

❗ Automation Restrictions: Strictly adhere to API call limits (usually 120 times per minute)

It is highly recommended to conduct a mock investment for at least 6 months before actual application.

Bitcoin
Momentum
Trading

0


Terms of ServicePrivacy PolicySupport
© 2025
I Wish I Had Known Earlier
All rights reserved.