home / skills / mkalhitti-cloud / universal-or-strategy / trading-session-timezones

trading-session-timezones skill

/.agent/skills/trading-session-timezones

This skill helps implement precise session-based trading for MES/MGC by handling Eastern Time zones and ORB timing to improve entry quality.

npx playbooks add skill mkalhitti-cloud/universal-or-strategy --skill trading-session-timezones

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
8.2 KB
---
name: trading-session-timezones
description: Trading session timing for MES/MGC futures with timezone handling. Use when implementing session-based entry/exit logic, ORB time windows, RTH detection, or handling global market overlaps.
---
# Trading Session Timezones - MES/MGC Futures

**Context:** Session timing for micro futures (MES/MGC) trading
**Critical For:** Opening Range Breakout (ORB), session-based entry/exit timing
**Platform:** NinjaTrader 8 with Rithmic data feed
**Universal Path:** `${PROJECT_ROOT}`
**Executors:** ${BRAIN} (Reasoning), ${HANDS} (Gemini Flash via delegation_bridge)

---

## Session Times (Eastern Time)

### RTH (Regular Trading Hours) - Primary Trading Window
```
Open:  09:30 ET
Close: 16:00 ET
```
**Best for:** ORB (9:30-10:00 setup), MOMO, all high-volume strategies
**Volume:** Highest - 50-200 ticks/min during active periods
**Spread:** Tightest (1-2 ticks typical)

### Globex (Extended Hours)
```
Open:  18:00 ET (previous day)
Close: 17:00 ET (current day)
```
**Best for:** Trend continuation, overnight gap setups
**Volume:** Moderate - 5-50 ticks/min
**Spread:** Wider (2-4 ticks typical)

### Pre-Market
```
Open:  04:00 ET
Close: 09:30 ET
```
**Best for:** ORB preparation, pre-market analysis
**Volume:** Low - 5-20 ticks/min
**Spread:** Wide (3-5 ticks)

---

## Code Implementation

### Detecting Session State
```csharp
private bool IsRTH()
{
    TimeSpan now = Time[0].TimeOfDay;
    TimeSpan rthOpen = new TimeSpan(9, 30, 0);
    TimeSpan rthClose = new TimeSpan(16, 0, 0);

    return now >= rthOpen && now < rthClose;
}

private bool IsORWindow()
{
    TimeSpan now = Time[0].TimeOfDay;
    TimeSpan orStart = new TimeSpan(9, 30, 0);
    TimeSpan orEnd = new TimeSpan(10, 0, 0);

    return now >= orStart && now < orEnd;
}
```

### Timezone Conversion for Multi-Market Trading
```csharp
// Convert ET to other timezones for global session awareness
private DateTime ConvertETToLocal(DateTime etTime)
{
    TimeZoneInfo et = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
    TimeZoneInfo local = TimeZoneInfo.Local;

    return TimeZoneInfo.ConvertTime(etTime, et, local);
}
```

---

## Optimal Trading Windows (Priority Tiers)

### Tier 1: Best Execution Quality (Target 100% of trades here)
```
09:30 - 12:00 ET  Morning session (ORB, MOMO, high volatility)
13:00 - 15:00 ET  Afternoon trends (RMA, TREND strategies)
```
**Characteristics:**
- Tightest spreads (1-2 ticks)
- Highest volume (100+ ticks/min)
- Best fills (slippage ≤ 2 ticks)
- Fastest execution (< 50ms)

### Tier 2: Acceptable Quality (Use selectively)
```
08:00 - 09:30 ET  Pre-market (ORB setup, low risk entries)
15:00 - 16:00 ET  Close (end-of-day moves)
```
**Characteristics:**
- Moderate spreads (2-3 ticks)
- Moderate volume (20-50 ticks/min)
- Acceptable fills (slippage ≤ 3 ticks)

### Tier 3: Avoid (Only for specific strategies)
```
19:00 - 22:00 ET  Evening Globex
04:00 - 08:00 ET  Early morning
```
**Characteristics:**
- Wide spreads (3-5 ticks)
- Low volume (< 20 ticks/min)
- Poor fills (slippage > 3 ticks)

### Dead Zones (Never Trade)
```
16:00 - 18:00 ET  Session transition (Rithmic may disconnect)
22:00 - 04:00 ET  Overnight (ultra-low volume)
```

---

## ORB Strategy Timing Requirements

### Setup Phase (9:30-10:00 ET)
```csharp
protected override void OnBarUpdate()
{
    if (!IsORWindow() || !IsFirstTickOfBar)
        return;

    // Capture high/low during OR window
    if (High[0] > sessionHigh)
        sessionHigh = High[0];
    if (Low[0] < sessionLow)
        sessionLow = Low[0];
}
```

### Trade Phase (10:00-12:00 ET)
```csharp
private bool IsORTradeWindow()
{
    TimeSpan now = Time[0].TimeOfDay;
    TimeSpan tradeStart = new TimeSpan(10, 0, 0);
    TimeSpan tradeEnd = new TimeSpan(12, 0, 0);

    return now >= tradeStart && now < tradeEnd;
}

protected override void OnBarUpdate()
{
    if (!IsORTradeWindow() || !orComplete)
        return;

    // Execute breakout trades
    if (Close[0] > sessionHigh + TickSize)
        ExecuteLong();
    else if (Close[0] < sessionLow - TickSize)
        ExecuteShort();
}
```

### Forced Exit (12:00 ET)
```csharp
protected override void OnBarUpdate()
{
    TimeSpan exitTime = new TimeSpan(12, 0, 0);

    if (Time[0].TimeOfDay >= exitTime && Position.MarketPosition != MarketPosition.Flat)
    {
        FlattenAll("ORB time exit");
    }
}
```

---

## Global Session Overlaps (For Multi-Market Awareness)

### Key Times in Eastern (ET)
```
20:00 ET (prev day)  China market open (Shanghai 9:00 AM)
01:00 ET             Tokyo market open (Tokyo 3:00 PM)
03:00 ET             London pre-market
08:00 ET             London RTH open
09:30 ET             New York RTH open ← PRIMARY FOCUS
```

### Overlap Impact on MES/MGC
- **London + NY (8:00-16:00 ET):** Highest volume period
- **Asia hours (20:00-03:00 ET):** Lower volume, wider spreads
- **NY solo (15:00-16:00 ET):** Moderate volume, end-of-day positioning

---

## Calendar-Based Filters

### High-Impact News Days (Avoid or Trade Cautiously)
```csharp
// Example: FOMC days - avoid 2 hours before/after announcement
private bool IsFOMCDay()
{
    // Hardcode FOMC dates or check economic calendar API
    DateTime[] fomcDates = { new DateTime(2025, 1, 29), new DateTime(2025, 3, 19) };
    return fomcDates.Contains(Time[0].Date);
}

protected override void OnBarUpdate()
{
    if (IsFOMCDay() && Time[0].TimeOfDay >= new TimeSpan(12, 0, 0))
    {
        // Pause trading or reduce position size
        return;
    }
}
```

### Weekly Patterns
```csharp
private bool IsFriday()
{
    return Time[0].DayOfWeek == DayOfWeek.Friday;
}

protected override void OnBarUpdate()
{
    // Reduce position size on Friday afternoons
    if (IsFriday() && Time[0].TimeOfDay >= new TimeSpan(14, 0, 0))
    {
        positionSizeMultiplier = 0.5;  // Half size
    }
}
```

---

## Rithmic Data Feed Session Behavior

### Expected Tick Frequency by Session
```csharp
private void MonitorTickHealth()
{
    int ticksPerMinute = tickCount / minutesSinceOpen;

    if (IsRTH() && ticksPerMinute < 20)
        Print("WARNING: RTH tick frequency low - Rithmic may be degraded");
    else if (!IsRTH() && ticksPerMinute < 5)
        Print("INFO: Normal overnight low volume");
}
```

### Session Transition Handling
```csharp
protected override void OnBarUpdate()
{
    // Close positions before session transitions to avoid gaps
    TimeSpan sessionTransition = new TimeSpan(15, 55, 0);

    if (Time[0].TimeOfDay >= sessionTransition && Position.MarketPosition != MarketPosition.Flat)
    {
        FlattenAll("Pre-session close");
    }
}
```

---

## Performance Optimization

### Cache Session Checks (Don't Recalculate Every Tick)
```csharp
private bool cachedIsRTH = false;
private DateTime lastSessionCheck = DateTime.MinValue;

private bool IsRTHCached()
{
    if (Time[0] != lastSessionCheck)
    {
        cachedIsRTH = IsRTH();
        lastSessionCheck = Time[0];
    }
    return cachedIsRTH;
}
```

### Execution Speed Target
- Session state checks: < 0.1ms
- OR window detection: < 0.1ms
- Forced exit logic: < 1ms total

---

## Quick Reference Table

| Session | ET Time | Ticks/Min | Spread | ORB | RMA | MOMO | TREND |
|---------|---------|-----------|--------|-----|-----|------|-------|
| RTH Morning | 9:30-12:00 | 100+ | 1-2 | ✅ Best | ✅ | ✅ Best | ✅ |
| RTH Afternoon | 12:00-16:00 | 50-100 | 1-2 | ❌ | ✅ | ⚠️ Lower | ✅ |
| Pre-Market | 4:00-9:30 | 5-20 | 3-5 | ⚠️ Setup | ⚠️ | ❌ | ❌ |
| Evening | 19:00-22:00 | 10-30 | 2-4 | ❌ | ⚠️ | ❌ | ⚠️ |
| Overnight | 22:00-4:00 | < 10 | 4-6 | ❌ | ❌ | ❌ | ❌ |

---

## Testing Checklist

Before deploying session-based logic:
- [ ] Verify timezone conversion (ET vs. local)
- [ ] Test OR window detection (9:30-10:00 exact)
- [ ] Test forced exit (12:00 ET exact)
- [ ] Verify session transition handling
- [ ] Test on historical data with session gaps
- [ ] Verify tick frequency monitoring works
- [ ] Test calendar filters (Friday, FOMC, etc.)

---

## Related Skills
- [wsgta-trading-system](../wsgta-trading-system/SKILL.md) - Strategy-specific session rules
- [universal-or-strategy](../universal-or-strategy/SKILL.md) - Project context
- [apex-rithmic-trading](../apex-rithmic-trading/SKILL.md) - Data feed session behavior
- [wearable-project](../antigravity-core/wearable-project.md) - Portability standards

Overview

This skill provides session timing and timezone-aware utilities for MES/MGC micro futures trading on NinjaTrader 8. It codifies RTH, Globex, pre-market windows, ORB setup/trade periods, and safe dead zones to drive entry/exit logic and calendar filters. The goal is reliable session detection, correct timezone conversion, and clear trading windows for automated strategies.

How this skill works

The skill exposes simple boolean checks (IsRTH, IsORWindow, IsORTradeWindow) and a ConvertETToLocal helper to ensure ET-based session logic works correctly on any host timezone. It includes cached session checks and tick-frequency monitoring to detect data feed degradation and session transitions for forced exits. Code snippets demonstrate ORB capture, forced exits, and calendar-based filters for high-impact events.

When to use it

  • Implementing ORB entry/exit logic tied to 9:30–10:00 ET setup and 10:00–12:00 ET trade windows.
  • Detecting RTH versus Globex to adjust position sizing, risk, and spread expectations.
  • Scheduling forced exits before session transitions or low-liquidity dead zones.
  • Converting ET session times to the local server timezone for multi-market deployments.
  • Pausing or reducing activity on high-impact news days (FOMC) or Friday afternoons.

Best practices

  • Keep session checks lightweight and cache results per bar to avoid per-tick recomputation.
  • Use explicit ET timezone IDs when converting times and validate TimeZoneInfo availability on host OS.
  • Prefer trading Tier 1 windows (09:30–12:00 ET) for ORB and high-volume strategies; avoid dead zones.
  • Implement tick-frequency health checks to detect Rithmic feed degradation and log warnings.
  • Enforce forced exits at defined times (e.g., 12:00 ET or session transition windows) to avoid overnight gaps.

Example use cases

  • ORB system: capture high/low during 9:30–10:00 ET, trade breakouts 10:00–12:00 ET, flatten at 12:00 ET.
  • Global deployments: convert ET session boundaries to server local time before scheduling automated orders.
  • Risk management: reduce position size on Fridays after 14:00 ET or pause trading around FOMC announcements.
  • Session-aware order routing: widen acceptable slippage/spread thresholds during Globex or pre-market hours.
  • Feed monitoring: trigger alerts when ticks/minute falls below expected thresholds during RTH.

FAQ

How do I handle daylight saving changes?

Use TimeZoneInfo with the 'Eastern Standard Time' ID and ConvertTime to let the OS handle DST transitions; validate on deploy.

What windows should I never trade?

Avoid session transition (16:00–18:00 ET) and overnight dead zones (22:00–04:00 ET) unless your strategy explicitly targets ultra-low liquidity.