Introduction to OFI
Order Flow Imbalance (OFI) detects aggressive buying and selling pressure by analyzing the order flow in the market. Unlike simple volume analysis, OFI identifies “smart money” activity by measuring the imbalance between market buy orders and market sell orders.
Key Advantages:
- ✅ Detects institutional/whale activity before major price moves
- ✅ Identifies accumulation and distribution phases
- ✅ Provides early entry signals before trend confirmation
- ✅ Superior to standard volume indicators
Signal Types Generated:
- OFI_BUY: Aggressive buying pressure detected
- OFI_SELL: Aggressive selling pressure detected
Understanding OFI Signals
How OFI Works
OFI measures the net aggressive order flow by comparing:
- Market Buy Orders: Orders that consume sell-side liquidity (aggressive buying)
- Market Sell Orders: Orders that consume buy-side liquidity (aggressive selling)
OFI Formula: (Aggressive Buys - Aggressive Sells) / Total Volume × 100
Signal Components
- Pressure Signals: Direct aggressive buying/selling detected
- Reversal Signals: Sentiment shift from selling to buying (or vice versa)
- Divergence Signals: OFI and price moving in opposite directions
Confidence Scoring
OFI signals include confidence scores (0-100%):
- 55-69%: Standard confidence (tradeable)
- 70-84%: High confidence (strong signals)
- 85-100%: Extreme confidence (rare, very strong)
Configuration Parameters
Core Settings
enable_ofi_signal: true
Master switch - Enable/disable all OFI functionality
OFI Calculation Parameters
ofi_lookback: 20
Purpose: Historical period for OFI analysis
Range: 10-50
Impact:
- Lower (10-15): More sensitive, faster signals, more noise
- Higher (30-50): Smoother signals, fewer false positives, slower response
Recommendations:
- Scalping: 10-15
- Day Trading: 15-25
- Swing Trading: 25-40
ofi_slope_period: 5
Purpose: Measures OFI momentum/acceleration
Range: 3-10
Impact:
- Lower: Catches momentum shifts faster
- Higher: Confirms sustained momentum
Recommendations:
- Fast momentum: 3-5
- Confirmed trends: 7-10
Threshold Settings
ofi_aggressive_buy_threshold: 65.0
Purpose: Minimum % imbalance to trigger OFI_BUY
Range: 55.0-80.0
Impact:
- Lower (55-60): More signals, including moderate pressure
- Higher (70-80): Only extreme buying pressure
Recommendations:
- High volatility markets (crypto): 60-65
- Low volatility markets (stocks): 65-70
- Conservative approach: 70-75
ofi_aggressive_sell_threshold: 65.0
Purpose: Minimum % imbalance to trigger OFI_SELL
Range: 55.0-80.0
Recommendations: Same as buy threshold
ofi_extreme_imbalance_threshold: 75.0
Purpose: Flags extraordinary imbalances (rare events)
Range: 70.0-85.0
Usage: Boosts confidence scores for exceptional opportunities
Signal Type Toggles
ofi_enable_pressure_signals: true
Direct aggressive buy/sell detection
- Most reliable OFI signal type
- Recommended: Always enabled
ofi_enable_reversal_signals: true
Detects sentiment shifts
- Example: Strong selling → sudden buying (potential bottom)
- Useful for: Counter-trend trading, catching reversals
- Risk: Can signal too early in strong trends
ofi_enable_divergence_signals: true
OFI vs Price divergence
- Example: Price falling but OFI showing buying (accumulation)
- Advanced signal type, requires experience
- Best for: Swing trading, identifying trend exhaustion
Filtering Options
ofi_min_slope_threshold: 0.0
Purpose: Filters weak momentum signals
Range: -5.0 to 5.0
Impact:
- 0.0: All signals pass
- Positive value (e.g., 2.0): Only signals with positive momentum
- Negative value: Only declining momentum signals
Use Cases:
- Trend following: Set 1.0-3.0 (only increasing OFI)
- Mean reversion: Set -3.0 to -1.0 (only decreasing OFI)
ofi_require_volume_confirmation: true
Purpose: Require above-average volume for signals
Recommendation: Always true for real trading; false only for testing/low liquidity markets
ofi_min_volume_multiplier: 1.2
Purpose: Volume must be X times average
Range: 1.0-2.5
Recommendations:
- Crypto (high volume): 1.2-1.5
- Low liquidity: 1.0-1.2
- Institutional focus: 1.5-2.0
Confidence Settings
ofi_min_confidence: 55.0
Purpose: Minimum score to generate signal
Range: 50.0-75.0
Recommendations:
- Aggressive trading: 55-60
- Balanced approach: 60-65
- Conservative: 65-75
ofi_high_confidence_threshold: 70.0
Purpose: Threshold for premium signals
Range: 65.0-80.0
Advanced Settings
ofi_normalize_by_timeframe: true
Purpose: Adjusts OFI calculations across different timeframes
Recommendation: Keep true for multi-timeframe strategies
ofi_smooth_data: false
Purpose: Applies moving average to reduce noise
When to enable:
- Very choppy markets
- Small timeframes (1m, 3m) with false signals
Drawback: Adds 1-2 bar delay
ofi_smoothing_period: 3
Purpose: Smoothing length (if enabled)
Range: 2-5
Recommendation: Use 3 for balance
Trading Strategy Configurations
1. Scalping Strategy (Quick Profits, High Frequency)
Objective: Capture quick OFI imbalances on small timeframes
enable_ofi_signal: true
ofi_lookback: 12
ofi_slope_period: 3
ofi_aggressive_buy_threshold: 60.0
ofi_aggressive_sell_threshold: 60.0
ofi_extreme_imbalance_threshold: 72.0
ofi_enable_pressure_signals: true
ofi_enable_reversal_signals: false # Too slow for scalping
ofi_enable_divergence_signals: false # Not useful for scalping
ofi_min_slope_threshold: 1.5 # Need positive momentum
ofi_require_volume_confirmation: true
ofi_min_volume_multiplier: 1.3
ofi_min_confidence: 55.0
ofi_high_confidence_threshold: 68.0
ofi_normalize_by_timeframe: true
ofi_smooth_data: false # Speed over smoothness
ofi_smoothing_period: 3
Best Timeframes: 1m, 3m, 5m
Exit Strategy: Quick (1:1.5 risk-reward, or opposite OFI signal)
Risk: High frequency means higher fees - ensure tight spreads
2. Day Trading Strategy (Intraday Trends)
Objective: Ride intraday OFI-confirmed trends
enable_ofi_signal: true
ofi_lookback: 20
ofi_slope_period: 5
ofi_aggressive_buy_threshold: 65.0
ofi_aggressive_sell_threshold: 65.0
ofi_extreme_imbalance_threshold: 75.0
ofi_enable_pressure_signals: true
ofi_enable_reversal_signals: true # Good for intraday pivots
ofi_enable_divergence_signals: true # Can catch trend exhaustion
ofi_min_slope_threshold: 0.5
ofi_require_volume_confirmation: true
ofi_min_volume_multiplier: 1.2
ofi_min_confidence: 60.0
ofi_high_confidence_threshold: 70.0
ofi_normalize_by_timeframe: true
ofi_smooth_data: false
ofi_smoothing_period: 3
Best Timeframes: 5m, 15m, 30m
Exit Strategy: Trail stop or opposite OFI signal + technical levels
Combine With: Support/resistance, moving averages
3. Swing Trading Strategy (Multi-Day Positions)
Objective: Identify accumulation/distribution for position trades
enable_ofi_signal: true
ofi_lookback: 30
ofi_slope_period: 7
ofi_aggressive_buy_threshold: 68.0
ofi_aggressive_sell_threshold: 68.0
ofi_extreme_imbalance_threshold: 78.0
ofi_enable_pressure_signals: true
ofi_enable_reversal_signals: true # Key for swing entry
ofi_enable_divergence_signals: true # Essential for swings
ofi_min_slope_threshold: 0.0 # All slopes valid
ofi_require_volume_confirmation: true
ofi_min_volume_multiplier: 1.4 # Need significant volume
ofi_min_confidence: 65.0 # Higher quality signals
ofi_high_confidence_threshold: 75.0
ofi_normalize_by_timeframe: true
ofi_smooth_data: true # Reduce noise on higher TF
ofi_smoothing_period: 3
Best Timeframes: 1h, 2h, 4h, 6h
Exit Strategy: Technical targets, trend reversal, weekly pivots
Holding Period: 2-10 days
4. Futures Trading Strategy (Leverage & Precision)
Objective: High-confidence OFI signals for leveraged positions
enable_ofi_signal: true
ofi_lookback: 18
ofi_slope_period: 5
ofi_aggressive_buy_threshold: 70.0 # Higher threshold for leverage
ofi_aggressive_sell_threshold: 70.0
ofi_extreme_imbalance_threshold: 80.0
ofi_enable_pressure_signals: true
ofi_enable_reversal_signals: true
ofi_enable_divergence_signals: false # Avoid false signals in leverage
ofi_min_slope_threshold: 2.0 # Strong momentum only
ofi_require_volume_confirmation: true
ofi_min_volume_multiplier: 1.5 # Need strong volume
ofi_min_confidence: 65.0 # Only quality signals
ofi_high_confidence_threshold: 75.0
ofi_normalize_by_timeframe: true
ofi_smooth_data: false
ofi_smoothing_period: 3
Best Timeframes: 5m, 15m, 30m, 1h
Risk Management: CRITICAL - use tight stops, lower position size
Leverage: 3-5x maximum recommended
Timeframe-Specific Settings
1-Minute (1m) Timeframe
Market Type: Extreme scalping, high noise
ofi_lookback: 10
ofi_slope_period: 3
ofi_aggressive_buy_threshold: 60.0
ofi_aggressive_sell_threshold: 60.0
ofi_min_confidence: 55.0
ofi_require_volume_confirmation: true
ofi_min_volume_multiplier: 1.4 # Need volume on 1m
ofi_smooth_data: true # Reduce noise
ofi_smoothing_period: 3
Notes:
- Very noisy - expect many signals
- Best during high liquidity hours
- Use strict volume confirmation
3-Minute (3m) Timeframe
ofi_lookback: 12
ofi_slope_period: 4
ofi_aggressive_buy_threshold: 62.0
ofi_aggressive_sell_threshold: 62.0
ofi_min_confidence: 57.0
ofi_smooth_data: false
Notes: Balanced between 1m chaos and 5m lag
5-Minute (5m) Timeframe
ofi_lookback: 15
ofi_slope_period: 5
ofi_aggressive_buy_threshold: 63.0
ofi_aggressive_sell_threshold: 63.0
ofi_min_confidence: 58.0
ofi_enable_reversal_signals: true
Notes: Sweet spot for active trading
15-Minute (15m) Timeframe
ofi_lookback: 20
ofi_slope_period: 5
ofi_aggressive_buy_threshold: 65.0
ofi_aggressive_sell_threshold: 65.0
ofi_min_confidence: 60.0
ofi_enable_divergence_signals: true
ofi_min_volume_multiplier: 1.2
Notes: Most reliable intraday timeframe
30-Minute (30m) Timeframe
ofi_lookback: 24
ofi_slope_period: 6
ofi_aggressive_buy_threshold: 66.0
ofi_aggressive_sell_threshold: 66.0
ofi_min_confidence: 62.0
ofi_enable_reversal_signals: true
ofi_enable_divergence_signals: true
Notes: Good for part-time traders
1-Hour (1h) Timeframe
ofi_lookback: 28
ofi_slope_period: 7
ofi_aggressive_buy_threshold: 67.0
ofi_aggressive_sell_threshold: 67.0
ofi_min_confidence: 63.0
ofi_smooth_data: true
ofi_smoothing_period: 3
Notes: Strong reliability, fewer false signals
2-Hour (2h) Timeframe
ofi_lookback: 30
ofi_slope_period: 7
ofi_aggressive_buy_threshold: 68.0
ofi_aggressive_sell_threshold: 68.0
ofi_min_confidence: 65.0
ofi_extreme_imbalance_threshold: 77.0
Notes: High confidence for position trades
6-Hour (6h) Timeframe
ofi_lookback: 35
ofi_slope_period: 8
ofi_aggressive_buy_threshold: 70.0
ofi_aggressive_sell_threshold: 70.0
ofi_min_confidence: 67.0
ofi_min_volume_multiplier: 1.5
Notes: Major accumulation/distribution only
1-Day (1d) Timeframe
ofi_lookback: 40
ofi_slope_period: 10
ofi_aggressive_buy_threshold: 72.0
ofi_aggressive_sell_threshold: 72.0
ofi_min_confidence: 70.0
ofi_enable_divergence_signals: true
ofi_extreme_imbalance_threshold: 80.0
Notes:
- Use for major position entries
- Combine with weekly/monthly chart analysis
Signal Actions & Broadcasting
Understanding Signal Action Types
The bot can handle OFI signals in two ways:
1. Automated Trading (supported_volatility_action)
Signals in this list will execute trades automatically
supported_volatility_action:
- "BUY" # Standard buy signal (from other indicators)
- "SELL" # Standard sell signal
- "PUMP" # Extreme bullish signal
- "CRASH" # Extreme bearish signal
- "OFI_BUY" # Add this to auto-trade OFI buy signals
- "OFI_SELL" # Add this to auto-trade OFI sell signals
2. Broadcasting Only (supported_volatility_action_broadcast)
Signals in this list will only send notifications (Discord/Telegram/WhatsApp)
supported_volatility_action_broadcast:
- "BUY"
- "SELL"
- "PUMP"
- "CRASH"
- "OFI_BUY" # Broadcast OFI buy signals
- "OFI_SELL" # Broadcast OFI sell signals
Configuration Strategies
Strategy A: Auto-Trade OFI Signals (Aggressive)
supported_volatility_action:
- "OFI_BUY"
- "OFI_SELL"
supported_volatility_action_broadcast:
- "PUMP"
- "CRASH"
Use When:
- You trust OFI signals completely
- Running tested, optimized parameters
- Automated trading strategy
Strategy B: Broadcast OFI, Trade Confirmed Signals (Balanced)
supported_volatility_action:
- "BUY" # Trade only confirmed multi-indicator signals
- "SELL"
supported_volatility_action_broadcast:
- "OFI_BUY" # Monitor OFI signals manually
- "OFI_SELL"
- "PUMP"
- "CRASH"
Use When:
- Testing OFI in live markets
- Want manual oversight
- Combining OFI with other indicators
Strategy C: Broadcast All, Trade High-Confidence Only (Conservative)
# Set ofi_min_confidence: 70.0 to filter for quality
supported_volatility_action:
- "OFI_BUY" # Only trades if confidence ≥70%
- "OFI_SELL"
supported_volatility_action_broadcast:
- "BUY" # Broadcast lower-confidence signals
- "SELL"
- "OFI_BUY"
- "OFI_SELL"
- "PUMP"
- "CRASH"
Use When:
- Capital preservation priority
- Want to see all signals but trade selectively
Strategy D: OFI for Alerts Only (Manual Trading)
supported_volatility_action:
- "BUY" # Trade other strategy signals
- "SELL"
supported_volatility_action_broadcast:
- "OFI_BUY" # Get OFI alerts on phone
- "OFI_SELL"
Use When:
- Manual discretionary trading
- Using OFI as supplementary confirmation
- Learning OFI behavior before automation
Broadcasting Best Practices
- Discord Setup: Best for detailed OFI analytics (includes confidence, slope, volume data)
- Telegram: Good for mobile alerts with quick trade decisions
- WhatsApp: Personal alerts, lower frequency recommended
- Alert Fatigue: On 1m-5m timeframes, consider:
- Higher confidence thresholds (65-70)
- Broadcasting only extreme imbalances
- Using separate channels for different timeframes
Best Practices & Tips
Getting Started with OFI
- Start with Broadcast Only
- Run for 1-2 weeks observing signals
- Note false positives and adjust thresholds
- Test on demo/paper trading first
- Optimize Per Asset
- Each market has different OFI characteristics
- Bitcoin: Higher thresholds (65-70)
- Altcoins: Lower thresholds (60-65) acceptable
- Stocks: Higher confidence needed (65-70)
- Time-of-Day Matters
- OFI works best during high-liquidity hours
- Avoid signals during market opens, low volume periods, major news events
Combining OFI with Other Indicators
Signal: OFI_BUY + RSI oversold (< 30)
Action: Strong reversal potential
Signal: OFI_BUY at major support level
Action: High-probability bounce
Signal: OFI_SELL at high volume node (resistance)
Action: Distribution confirmed
Signal: OFI_BUY + price above 50 EMA
Action: Trend continuation confirmed
Common Mistakes to Avoid
- Setting Thresholds Too Low
Result: Signal spam, over-trading
Fix: Start at 65%, adjust down only if needed - Ignoring Volume Confirmation
Result: False signals on low liquidity
Fix: Always keepofi_require_volume_confirmation: true - Using Divergence Signals on Fast Timeframes
Result: Whipsaws on 1m-5m
Fix: Divergence only on 1h+ - Over-Optimizing Parameters
Result: Strategy works in backtest, fails live
Fix: Use default values, make small adjustments - Trading OFI Against Major Trend
Result: Catching falling knives
Fix: Use higher timeframe context (e.g., 1h trend for 5m OFI signals)
Performance Monitoring
Track these metrics weekly:
OFI Signal Win Rate: [Target: >55%]
Average Confidence of Winners: [Target: >65]
Average Confidence of Losers: [Track if < 60, adjust min_confidence]
Signals Per Day: [Adjust thresholds if too many/few]
Best Performing Timeframe: [Focus optimization here]
Advanced Techniques
# Multi-Timeframe OFI Confirmation
# Check 15m for OFI_BUY, confirm with 1h
# Execute on 5m timeframe
# Strongest signals have alignment across 3 timeframes
OFI Clustering
When multiple OFI_BUY signals cluster within 30 minutes:
= Institutional accumulation likely
= Increase position size by 30-50%
OFI + Order Book Depth
OFI_BUY + Large bid walls appearing = Whale accumulation confirmed = Very high probability setup
Troubleshooting
| Problem | Likely Cause | Solution |
|---|---|---|
| No signals generating | Thresholds too high | Lower to 60-62 |
| Too many signals | Thresholds too low | Raise to 68-70 |
| All signals losing | Wrong timeframe | Try 15m instead of 1m |
| Signals lag price | Lookback too high | Reduce to 15-18 |
| False reversals | Enable reversal too soon | Disable for faster timeframes |
| Low confidence scores | Volume multiplier too high | Lower to 1.1-1.2 |
Quick Reference: Recommended Presets
Conservative (Low Risk)
ofi_aggressive_buy_threshold: 70.0
ofi_min_confidence: 65.0
ofi_min_volume_multiplier: 1.4
ofi_enable_reversal_signals: false
Balanced (Default)
ofi_aggressive_buy_threshold: 65.0
ofi_min_confidence: 60.0
ofi_min_volume_multiplier: 1.2
ofi_enable_reversal_signals: true
Aggressive (High Frequency)
ofi_aggressive_buy_threshold: 60.0
ofi_min_confidence: 55.0
ofi_min_volume_multiplier: 1.1
ofi_enable_reversal_signals: true
ofi_enable_divergence_signals: true
Final Notes
- OFI signals are most powerful when volume confirmation is enabled
- Always backtest parameter changes before live trading
- OFI works best in trending markets, less reliable in tight ranges
- Combine with risk management: stop losses are mandatory
- High confidence OFI signals (>70%) are rare but extremely valuable