Session/Time Filters

Time Range Filter (MT5): Session-Based Entry Timing Guide | AlfaTactix

📖 10 min read

📝 1,848 words

🏷️ Session/Time Filters

In this page: what Time Range is, how it works, when to use it, a practical example, and a bonus tip.

Use Time Range in a real strategy—no code required

Create a free account to save your progress and add this filter (and others) to strategies in minutes. Backtest, then export to MQL5.


Filter Explanation

Time Range Filter Explanation

The Time Range Filter is a flexible time-based trading filter that allows you to filter trades based on specific time periods, days of the week, and custom time windows. This powerful filter helps optimize entry timing by focusing on periods when market conditions are most favorable for your trading strategy, avoiding low-liquidity periods and aligning trades with optimal market activity. Research demonstrates that time-based filtering can improve strategy performance by 10-20% by avoiding unfavorable trading hours and focusing on periods with optimal liquidity and volatility patterns.

How Time Range Filtering Works:

Time range filtering operates by checking the current market time against predefined time windows and day-of-week conditions before allowing trade execution. This systematic approach helps traders avoid periods when market conditions are suboptimal due to low participation, wide spreads, or other time-based factors that negatively impact execution quality and strategy performance.

Key Features:

Time-Based Filtering:

  • Specific Hours: Filter trades to specific hours (e.g., 09:00-17:00 UTC) when you're actively monitoring or when market conditions are optimal. This ensures trades are executed only during your designated active trading hours, aligning strategy execution with your availability and optimal market conditions.

  • Time Windows: Create custom entry windows (e.g., 10:00-11:00 UTC) for specific strategy types. Some strategies perform better during specific time windows - for example, gap trading strategies may target market opening hours, while breakout strategies may focus on high-volatility periods.

  • Session Alignment: Align time ranges with trading sessions or market news events. By matching your time filter to known high-activity periods (e.g., London session opening, US market open), you can maximize exposure to periods with optimal liquidity and volatility.

  • Multiple Time Windows: Define multiple allowed time windows within a single day, allowing flexibility for strategies that benefit from trading during specific periods while avoiding others.

Day-of-Week Filtering:

  • Weekday Trading: Trade only on specific days (e.g., Monday through Thursday) to avoid weekend gaps and Friday volatility. Many traders exclude Friday trading to avoid weekend gap risk and reduced liquidity during Friday afternoons.

  • Friday Caution: Many traders avoid Friday trading due to increased volatility and potential weekend gaps. Friday afternoons typically show reduced liquidity as institutions reduce exposure before the weekend, leading to wider spreads and increased gap risk.

  • Monday Patterns: Some strategies target Monday openings due to gap trading opportunities. Monday mornings often show higher volatility as markets react to weekend news and gaps from Friday's close.

  • Mid-Week Focus: Tuesday through Thursday are typically the most stable trading days, with consistent liquidity and volatility patterns, making them ideal for many systematic strategies.

Custom Time Conditions:

  • Before/After Specific Times: Filter trades before or after specific times (e.g., avoid trades after 20:00 UTC). This helps avoid low-liquidity periods that occur during late evening hours or early morning hours in certain time zones.

  • Exclude Weekends: Automatically skip weekend periods when markets are closed (forex markets close Friday evening and reopen Sunday evening). This prevents strategy logic from attempting trades during closed market periods.

  • Time Remaining: Calculate time remaining until market close or session end. This allows dynamic adjustment of position sizing or risk parameters as market close approaches.

  • Holiday Handling: Configure automatic exclusion of trading days around major holidays when liquidity is significantly reduced and market behavior is atypical.

Why Use Time Range Filters:

  • Reduces False Signals: Low-activity periods (early morning, late evening, weekends) often produce false signals due to thin liquidity, wide spreads, and reduced market participation. Time filters help avoid these periods, improving signal quality by 15-25% according to backtesting studies.

  • Optimizes Execution: Trade during hours when spreads are tightest and liquidity is highest. During high-liquidity periods, spreads can be 50-70% tighter than during low-activity periods, significantly reducing transaction costs.

  • Aligns with Schedule: Match trading hours with your monitoring schedule for better strategy management. This ensures you can actively monitor positions during allowed trading hours, improving risk management and strategy oversight.

  • News Event Avoidance: Exclude times around major news events to reduce volatility spikes and execution difficulties. Many traders avoid trading during high-impact news releases (e.g., NFP, FOMC announcements) to avoid unpredictable price movements and execution challenges.

  • Strategy-Specific Windows: Some strategies work better at specific times - for example, scalping strategies benefit from high-liquidity hours, while swing trading strategies may work better during quieter periods with less noise.

  • Risk Management: Time filters can help manage weekend gap risk by automatically closing positions or avoiding new entries before market close, reducing exposure to unexpected weekend events.

Common Time Patterns:

Research has identified consistent time-based patterns that traders can leverage:

  • Asian Session (00:00-09:00 GMT): Lower volatility, good for range trading strategies. Spreads are typically wider, but price movements are more predictable and less erratic.

  • European Session (08:00-16:00 GMT): High volatility for EUR and GBP pairs, making it ideal for breakout and momentum strategies targeting European currencies.

  • US Session (13:00-21:00 GMT): High volatility for USD pairs, especially during the first two hours when US traders enter. This session is optimal for USD-focused strategies.

  • Overlap Periods: Highest liquidity and tightest spreads occur during session overlaps (e.g., London-New York overlap from 12:00-16:00 GMT), making these periods ideal for most trading strategies.

  • After-Hours: Lower liquidity, wider spreads (typically 2-3x normal spreads), avoid for most strategies. These periods show reduced market participation and increased execution risk.

  • Pre-Market/Post-Market: In equity markets, pre-market and post-market hours show significantly reduced liquidity compared to regular trading hours, making time filtering essential for equity strategies.

Advantages:

  • Provides objective time-based filtering that adapts to different market conditions and time zones, making it ideal for optimizing trade timing across various strategies and instruments.

  • Works across all markets and timeframes, as time-based patterns apply universally. Whether trading forex, stocks, or commodities, time filters help optimize execution timing.

  • Can be combined with other filters (session filters, volatility filters, liquidity filters) for enhanced precision, creating sophisticated multi-factor entry conditions.

  • Helps manage risk by avoiding low-liquidity periods when execution quality degrades and slippage increases significantly.

  • Improves consistency by ensuring trades are executed during optimal market conditions, reducing variance in execution quality and strategy performance.

Limitations:

  • Time zones and daylight saving time changes can complicate time filter configuration, requiring periodic adjustments. Some platforms automatically handle timezone conversions, while others require manual configuration.

  • Market conditions can override time-based patterns - major news events or market crises can create volatility during typically quiet hours, while calm markets can reduce activity during typically active hours.

  • Over-restrictive time filters may cause missed opportunities when legitimate moves occur outside allowed hours due to news or other factors.

  • Different instruments may have different optimal trading hours, requiring instrument-specific time filter configurations.

  • Should be combined with other analysis tools for optimal results. Time filters work best when combined with volatility filters, session filters, and market condition analysis.

In summary, the Time Range filter is an essential tool for traders focused on optimizing entry timing based on time-based market patterns, helping maximize execution quality while minimizing exposure to unfavorable trading hours. For further reading, refer to Harris's comprehensive work "Trading and Exchanges: Market Microstructure for Practitioners" (2003), Investopedia's guide to best times to trade forex, academic research on intraday market patterns and time-of-day effects published in journals such as the Journal of Financial Markets, and institutional research on optimal trading hours by major brokers and trading platforms.


Practical Example

Practical Example: Using Time Range Filter

The Time Range Filter is a time-based filter used to ensure trades are entered only during specific time periods and days of the week when market conditions are optimal. In a trading strategy, the time range filter helps optimize execution quality and reduce risk by focusing on periods with optimal liquidity and avoiding low-activity periods that can lead to poor execution.

Scenario: You're creating a breakout strategy for EUR/USD and want to trade only during European business hours (09:00-17:00 UTC) on weekdays (Monday through Friday), avoiding weekends, early morning hours, late evening hours, and Friday afternoons to minimize weekend gap risk.

Strategy Logic:

  • Filter trades to execute only between 09:00-17:00 UTC on weekdays (Monday-Friday)
  • Exclude weekends (Saturday, Sunday) automatically
  • Optionally exclude Friday afternoons (after 15:00 UTC) to reduce weekend gap exposure
  • Skip all trades outside these time windows to avoid low-liquidity periods with wider spreads and higher slippage
  • Align time range with peak European trading hours when EUR pairs show highest liquidity and tightest spreads

Backtrader Example:

import backtrader as bt
from datetime import datetime, time
from datetime import date

class TimeRangeFilterStrategy(bt.Strategy):
    params = dict(
        start_time=time(9, 0),    # 09:00 UTC
        end_time=time(17, 0),     # 17:00 UTC
        friday_end_time=time(15, 0),  # 15:00 UTC on Fridays
        exclude_weekends=True,
        exclude_friday_afternoon=True
    )
    
    def __init__(self):
        self.order = None
        
    def is_within_time_range(self, dt):
        """Check if current time is within allowed time range"""
        current_time = dt.time()
        current_weekday = dt.weekday()  # 0=Monday, 6=Sunday
        
        # Exclude weekends
        if self.p.exclude_weekends and current_weekday >= 5:  # Saturday (5) or Sunday (6)
            return False
        
        # Check Friday afternoon exclusion
        if self.p.exclude_friday_afternoon and current_weekday == 4:  # Friday
            return self.p.start_time <= current_time <= self.p.friday_end_time
        
        # Regular time check for Monday-Thursday
        return self.p.start_time <= current_time <= self.p.end_time
    
    def next(self):
        current_dt = self.data.datetime.datetime(0)
        
        # Time range filter: only trade during allowed time windows
        if not self.is_within_time_range(current_dt):
            return  # Skip trade if outside allowed time range
        
        if not self.position:
            # Your entry logic here (e.g., breakout detection)
            if self._breakout_detected():
                self.buy()
        else:
            # Exit logic (e.g., stop-loss, take-profit, or opposite signal)
            if self._exit_condition():
                self.close()
    
    def _breakout_detected(self):
        # Add your breakout detection logic here
        # Example: price breaks above 20-period high
        return False
    
    def _exit_condition(self):
        # Add your exit logic here
        return False

# Usage
cerebro = bt.Cerebro()
cerebro.addstrategy(TimeRangeFilterStrategy)

Expected Outcome: By using the Time Range filter, your strategy ensures:

  • Optimal Liquidity: Trading during active European hours (09:00-17:00 UTC) when spreads are tightest (typically 0.5-1 pip for EUR/USD) and liquidity is highest
  • Reduced Weekend Gap Risk: Avoiding Friday afternoon trades (after 15:00 UTC) minimizes exposure to weekend news events and unexpected gap moves
  • Better Execution: Higher liquidity periods provide faster fills with minimal slippage, improving entry and exit prices
  • Consistent Performance: By avoiding low-activity periods (early morning, late evening), you reduce execution variance and improve strategy consistency
  • Lower Transaction Costs: Trading only during optimal hours reduces spread costs by 30-50% compared to trading throughout all hours

💡 Bonus Tip

For EUR/USD, the 09:00-11:00 UTC window (early European session) often shows strong directional moves as European traders enter the market, making it ideal for breakout strategies. Similarly, the 14:00-16:00 UTC window (London-New York overlap) offers peak liquidity with spreads below 1 pip. Consider combining time range filters with session filters and volatility filters for maximum effectiveness - only trade during your allowed time windows when volatility is also expanding and liquidity is high. This multi-factor approach can improve win rates by 10-20% while reducing transaction costs.

Using the Time Range filter ensures your strategy aligns with optimal trading hours, improving execution quality and overall performance over time by focusing on periods with the highest probability of success.

Use Time Range in a real strategy—no code required

Create a free account to save your progress and add this filter (and others) to strategies in minutes. Backtest, then export to MQL5.

Try Strategy Builder

Use this filter in Strategy Builder — free

Create free account