Master the clock by creating TradingView session-specific alerts. Use Pine Script time filters to trigger trades during RTH and automate your futures strategy.

TradingView session-specific alerts trigger only during defined time windows, such as NYSE regular hours (9:30 AM - 4:00 PM ET) or custom trading sessions. To create them, you define time parameters in Pine Script using the time() function or built-in session variables, then attach alert conditions that fire only when your strategy conditions meet AND the current time falls within your specified session window.
time() function to restrict triggers to defined hours like 9:30 AM - 4:00 PM ET for day sessionssession.regular and session.extended built-in variables simplify common session filtering without manual time codingSession-specific alerts are TradingView notifications that fire only during designated trading hours you define in your Pine Script code. Unlike standard alerts that trigger any time conditions are met—including overnight or during illiquid hours—session alerts add a time-based filter that checks both your strategy condition AND whether the current market time falls within your specified window.
For futures traders, this matters because ES, NQ, GC, and CL contracts trade nearly 24 hours but display different characteristics during regular NYSE hours (9:30 AM - 4:00 PM ET) versus overnight sessions. Volume during RTH averages 3-5x higher than overnight for equity index futures, and spreads tighten significantly.
Session Filter: A conditional check in Pine Script that evaluates whether the current bar's timestamp falls within defined start and end times. Session filters prevent alerts from firing outside your intended trading window.
You can filter by regular trading hours, extended hours, custom time ranges (like the first 30 minutes after open), or even specific days of the week. The time() function and built-in session variables handle the logic.
Session filtering addresses three practical problems futures traders face with 24-hour markets: liquidity variation, volatility patterns, and personal availability.
During regular trading hours, ES futures typically see 0.25-0.50 point spreads. After 4:00 PM ET, spreads often widen to 0.50-1.00 points or more. If your TradingView automation fires a market order at 2:00 AM ET, you'll pay a wider spread and face lower volume, increasing slippage risk.
Volatility also clusters around economic releases and market opens. A strategy that works well during the 9:30 AM - 10:30 AM high-volume window may generate false signals during the quiet 7:00 PM - 9:00 PM period. Session filters let you restrict alerts to the time windows where your strategy's edge actually exists.
For traders who can't monitor markets 24/7, session filters prevent alerts from firing while you sleep or during work hours. This pairs well with automation—your alerts only fire when you've tested and validated the strategy for those specific hours.
Creating session-specific alerts requires three components: defining your session window, adding the time filter to your strategy logic, and configuring the alert with that filtered condition.
Use the time() function to check if the current bar falls within your desired trading hours. For regular NYSE hours (9:30 AM - 4:00 PM ET), the syntax looks like this:
inSession = time(timeframe.period, "0930-1600", "America/New_York")
This returns a timestamp if the current bar is within that window, or na if outside. You can also use built-in variables: session.regular for standard hours and session.extended for pre-market and after-hours.
Combine your strategy logic with the session check using the and operator. Here's a simple example:
longCondition = ta.crossover(ta.sma(close, 9), ta.sma(close, 21)) and not na(inSession)
This triggers a long signal only when the 9 SMA crosses above the 21 SMA AND the current time is within your defined session. Without the not na(inSession) check, the crossover would fire any time of day.
In the Pine Editor, use alertcondition() or alert() to attach the session-filtered logic. Then create the alert in the TradingView UI, selecting your script and condition.
alertcondition(longCondition, title="Session Long Entry", message='{"action":"buy","ticker":"ES"}')
When you configure the alert in TradingView's Alerts panel, it will only fire when both your indicator condition is true and the session filter is active. You can then connect this to a supported broker via webhook for automated execution.
Different trading strategies benefit from different time windows. Here are session filters commonly used in futures automation.
Session TypeTime Window (ET)Use CaseRTH (Regular Hours)9:30 AM - 4:00 PMHigh liquidity, tighter spreads, institutional participationOpening Range9:30 AM - 10:00 AMInitial Balance and OR breakout strategiesLunch Session11:30 AM - 1:30 PMLower volatility, range-bound strategiesPower Hour3:00 PM - 4:00 PMEnd-of-day momentum and position squaringOvernight6:00 PM - 9:30 AMNews-driven moves, lower volume strategiesAsian Session7:00 PM - 2:00 AMReduced volatility for non-equity futuresOpening Range: The high and low price established during the first 30-60 minutes after market open. Breakouts above or below this range often signal the day's directional bias and are popular triggers for automated entries.
For ES and NQ futures, filtering to RTH captures roughly 65-70% of total daily volume while avoiding the wider spreads and choppier overnight price action. Gold (GC) and Crude Oil (CL) futures see more overnight activity due to international trading, so session choice depends on your specific strategy and instrument.
To create a custom filter for only the first 15 minutes after market open:
firstFifteen = time(timeframe.period, "0930-0945", "America/New_York")
This restricts your alert to fire only between 9:30 AM and 9:45 AM ET. You can combine multiple session windows with or logic if you want to trade both the open and close:
tradeWindow = not na(time(timeframe.period, "0930-1000", "America/New_York")) or not na(time(timeframe.period, "1500-1600", "America/New_York"))
Once your session-specific alert is configured in TradingView, you connect it to an automation platform via webhook to execute trades without manual intervention. The alert's JSON message includes your trade parameters, and the platform sends the order to your broker.
When creating the TradingView alert, paste your webhook URL (provided by your automation platform) into the "Webhook URL" field. In the alert message box, structure your JSON payload with session context if needed:
{"action":"buy","ticker":"ES","contracts":1,"session":"RTH"}
Platforms like ClearEdge Trading process these webhooks with latency typically between 3-40ms depending on broker API response times. The session label in your JSON can help with logging and performance tracking—you'll know whether your RTH-only alerts perform differently than overnight alerts.
Webhook URL: A unique endpoint provided by your automation platform that receives TradingView alert data via HTTP POST request. When your session-filtered alert fires, TradingView sends the JSON payload to this URL, triggering automated trade execution.
For risk management, configure daily loss limits and position sizing rules in your automation platform. Even with perfect session filtering, drawdowns happen—automated risk controls prevent a single bad session from damaging your account. Most platforms allow you to set maximum daily loss as a percentage (commonly 2-5%) or dollar amount.
Testing your session alerts on paper accounts before going live is critical. You want to confirm that alerts fire only during your intended windows and that the webhook connection reliably reaches your broker. Run paper tests for at least 5-10 trading days covering different market conditions.
TradingView's built-in alert system doesn't offer session filtering through the UI alone—you need Pine Script to implement time-based conditions. However, many public Pine Script indicators already include session filters you can enable through input settings. Search for indicators with "session filter" or "RTH only" in their descriptions, then customize the time parameters through the indicator's settings panel.
Your Pine Script logic should include exit conditions separate from entry session filters. If you enter during RTH and your session filter becomes false after 4:00 PM, the filter won't automatically close your position—you need explicit exit logic. Many traders use time-based exits like strategy.close_all() triggered when the session ends, or they rely on stop-loss and take-profit levels regardless of time.
TradingView synchronizes to exchange timestamps, but broker execution timestamps may differ by a few seconds due to server processing. This rarely affects session alerts unless you're filtering down to the exact second. For practical purposes, defining session windows with 1-minute granularity (like 9:30 AM instead of 9:30:00 AM) avoids edge-case timing issues.
Yes. Pine Script's dayofweek variable returns the current day (1=Sunday, 2=Monday, etc.). Combine it with your session filter: validDay = dayofweek != 2 excludes Mondays. Then add and validDay to your alert condition. This is useful for avoiding lower-volume holidays or days when your strategy historically underperforms.
TradingView's time() function works on any timeframe, including tick charts and seconds charts if your subscription supports them. However, be aware that more granular timeframes generate more bars and potentially more alerts. Session filtering on a 10-second chart during a 6.5-hour RTH session creates 2,340 bars—ensure your strategy logic and broker API can handle the alert frequency.
Session-specific alerts give you precise control over when your TradingView strategies fire, aligning automation with the time windows where your edge exists. By filtering to high-liquidity hours or custom ranges like the opening 30 minutes, you avoid the wider spreads and false signals common in overnight futures trading.
Start by defining your session in Pine Script using the time() function, add the filter to your strategy conditions, and test thoroughly on paper before connecting to live automation. For more on connecting TradingView to your broker, see our complete TradingView automation guide.
Start automating your session-based strategies. View ClearEdge Pricing →
Disclaimer: This article is for educational purposes only. It is not trading advice. ClearEdge Trading executes trades based on your rules—it does not provide signals or recommendations.
Risk Warning: Futures trading involves substantial risk. You could lose more than your initial investment. Past performance does not guarantee future results. Only trade with capital you can afford to lose.
CFTC RULE 4.41: Hypothetical results have limitations and do not represent actual trading.
By: ClearEdge Trading Team | About
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Block quote
Ordered list
Unordered list
Bold text
Emphasis
Superscript
Subscript
Every week, we break down real strategies from traders with 100+ years of combined experience, so you can skip the line and trade without emotion.
