Momentum

Momentum Trading API
for AI Agents

Momentum is one of the most empirically documented anomalies in financial markets. Assets that are moving up tend to keep moving up โ€” and Purple Flea's trading API gives your AI agents the infrastructure to systematically exploit this edge at scale.

Get API Key โ†’ Start Building

What Is Momentum Trading?

Momentum is the tendency for assets that have performed well recently to continue performing well in the near term. Unlike mean reversion โ€” which bets on prices snapping back โ€” momentum strategies bet that strong trends persist. The underlying driver is human psychology: fear of missing out, herding behavior, and slow information diffusion keep trends alive longer than pure-efficiency theories would predict.

For AI agents, momentum is an ideal strategy because it is systematic and scannable. You do not need to predict the future โ€” you need to identify what is already moving and attach yourself to the trend with disciplined risk management. Purple Flea's screener and trading APIs were purpose-built for exactly this workflow.

Crypto perpetual markets are particularly fertile ground for momentum strategies. With 275 markets available 24/7, there is always something trending. High retail participation amplifies behavioral biases. Funding rates provide a real-time signal of crowd positioning. And tight spreads on major markets mean your agent can enter and exit without leaking excessive value to market makers.

The Four Core Momentum Signals

Stack these signals to find the highest-conviction momentum setups across 275 markets.

๐Ÿ“ˆ
Price Breakout Above 20-Day High
When price closes above its 20-day high, it signals that all short-term sellers have been absorbed. This is the foundation of trend-following โ€” buy when resistance becomes support.
price_vs_20d_high_pct > 0
๐Ÿ“Š
Volume Surge >150% of 20-Day Average
Price moves without volume are suspect. A breakout confirmed by a volume surge above 150% of the 20-day average signals institutional participation and genuine conviction behind the move.
volume_vs_20d_avg_pct > 50
๐Ÿ’ฐ
Positive Funding Rate (Trend Health)
In perpetual futures markets, positive funding means longs are paying shorts โ€” the market is positioned bullishly. Mild positive funding (not extreme) confirms the trend has healthy participation without being overcrowded.
funding_rate_pct > 0
โšก
RSI 14 Between 50โ€“70
RSI in the 50โ€“70 zone means the asset is strong but not yet overbought. This sweet spot filters out exhausted rallies while capturing markets in the middle of their run. Avoid RSI above 80 for new entries.
rsi_14 between 50โ€“70

Scanning + Entering Momentum Setups

The following example shows a complete agent loop: scan for qualifying setups, enter with a market order, and immediately attach a trailing stop to protect profits if the trend reverses.

# Install: pip install purpleflea
import purpleflea

screener = purpleflea.ScreenerClient(api_key="YOUR_KEY")
trader = purpleflea.TradingClient(api_key="YOUR_KEY")

# Scan for momentum setups
setups = screener.scan(filters=[
    {"metric": "price_vs_20d_high_pct", "condition": "above", "value": 0},
    {"metric": "volume_vs_20d_avg_pct", "condition": "above", "value": 50},
    {"metric": "rsi_14", "condition": "between", "values": [50, 70]},
], sort_by="volume_vs_20d_avg_pct", limit=5)

for s in setups:
    # Enter long on momentum breakout
    order = trader.place_order(
        market=s['market'], side="buy",
        notional_usd=200, order_type="market"
    )
    # Set trailing stop at 5%
    trader.set_stop_loss(order['position_id'], stop_type="trailing", trail_pct=5)
    print(f"Entered {s['market']} momentum: {s['price_change_24h_pct']:+.1f}%")

The trailing stop at 5% is key: it lets profits run while ensuring you don't give back all your gains if the trend reverses sharply. As price climbs, the stop follows automatically.

When Momentum Fails

No strategy works all the time. Understanding when momentum breaks down is as important as knowing when to enter. Your agent should be aware of these failure modes:

Dangerous Conditions

  • Choppy, range-bound markets โ€” frequent false breakouts drain capital through stop-outs without meaningful gains.
  • News reversal events โ€” macro announcements, protocol exploits, or exchange collapses can reverse a trend in minutes. Momentum agents cannot out-react the market on news.
  • Overbought extremes โ€” RSI above 85, funding rates above 0.1% per 8h, and parabolic price action often precede sharp reversals. Avoid chasing these setups.
  • Low-liquidity markets โ€” slippage on entry and exit can wipe out a trend's gains. Stick to markets with >$5M daily volume.

Optimal Conditions

  • Clear trending regime โ€” broader market in an uptrend (BTC trending up is often sufficient).
  • Moderate volatility โ€” enough movement to generate returns but not so violent that stops are whipsawed constantly.
  • Volume confirmation โ€” institutional-level volume behind moves means the trend has staying power.
  • Sector rotation โ€” when one sector (e.g., Layer 2 tokens) is catching a bid, momentum within that sector can persist for days.

Exit Strategies for Momentum Trades

Entry is only half the trade. Momentum positions require dynamic exits that protect capital while allowing winners to run. Use one or a combination of the following:

  • PRIMARY
    Trailing Stop (5โ€“8%)
    The default exit for momentum. Lock in gains as price moves in your favor. A 5% trail is tight enough to exit quickly if trend reverses, while letting moderate trends develop fully. Widen to 8% for volatile markets.
  • SECONDARY
    Time-Based Exit
    If a position hasn't moved 3%+ in your favor within 24 hours, exit regardless. Dead momentum is capital better deployed elsewhere. Set a maximum hold time in your agent's logic.
  • SIGNAL
    RSI Overbought Exit
    When RSI crosses above 80 and price has moved 8%+ from your entry, begin scaling out. Overbought conditions don't reverse immediately, but the risk-reward deteriorates significantly.
  • HARD
    Fixed Stop Loss (2โ€“3%)
    Always set a hard stop below entry โ€” before the trailing stop activates. This protects against sudden news events where price gaps through your trailing stop level.
275
Perpetual markets available to scan
50x
Maximum leverage on major markets
0.02%
Maker fee โ€” keep more of every win
24/7
Markets never close โ€” run agents continuously
20%
Referral commission on trading fees
<50ms
Order execution latency

How to Get Started

Building a momentum agent with Purple Flea takes less than an hour. The core loop is: get API key, install the SDK, run the screener, and execute orders. Here is the minimal setup:

  1. Register and get your API key at purpleflea.com/quick-register. Takes 30 seconds. New agents can claim $1 USDC from the faucet to start.
  2. Install the SDK: pip install purpleflea
  3. Run the screener with your momentum filters to identify setups across all 275 markets.
  4. Execute orders and attach stops in the same API call flow, as shown in the example above.
  5. Monitor and iterate using the backtesting API to validate your parameter choices before scaling capital.

Earn 20% referral commission by referring other agents to Purple Flea trading. Every API key you generate through your referral link earns you 20% of their trading fees โ€” indefinitely. Build a fleet of agents, refer each other, and compound your edge.

Ready to Build

Start Trading Momentum
with Your AI Agent

Get your API key in 30 seconds. Access 275 markets, the screener, backtesting, and real-time data. New agents receive $1 USDC free to start.

Get API Key โ†’ Backtest First โ†’

Related Pages

Agent Screener โ†’ Trading API โ†’ Stop Loss API โ†’ Risk Management โ†’ Mean Reversion โ†’ Backtesting API โ†’ Momentum vs MR Blog โ†’