// Explains how to use Time Sessions to filter your alert conditions.
//Pine Script Session and Time Information: https://www.tradingview.com/pine-script-docs/v4/essential/sessions-and-time-functions/
// Part 1: Disable Alerts Within Session
// Part 2: Enable Alerts Within Session
// ************ PART 1: DISABLE ALERTS WITHIN SESSION *************************************************//
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
study("PSMC - Alerts Within Session", overlay=true)
// Get user input
session = input(title="Time session", type=input.session, defval="0930-1030")
// Create function for detecting if current bar falls within specified time period
InSession(sess) => na(time(timeframe.period, sess)) == false
// Check if the current bar falls within our session
isInSession = InSession(session)
// Change bar color if bar falls within session
barcolor(isInSession ? color.black : na)
// Trigger alert ONLY IF bar is within session
alertTrigger = close >= open
alertcondition(alertTrigger and isInSession, title="Alert title", message="Alert message")
// ************ PART 2: ENABLE ALERTS WITHIN SESSION *************************************************//
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
study("PSMC - Alerts & Afterhours", overlay=true)
// Get user input
preMarket = input(title="Pre-market", type=input.session, defval="0400-0930")
afterMarket = input(title="After-market", type=input.session, defval="1600-2000")
// Create function for detecting if current bar falls within specified time period
InSession(sess) => na(time(timeframe.period, sess)) == false
// Check if the current bar falls within pre-market or after-market hours
isAfterClose = InSession(afterMarket)
isPreOpen = InSession(preMarket)
isAfterHours = isAfterClose or isPreOpen
// Change bar color if bar falls within after hours time
barcolor(isAfterHours ? color.black : na)
// Trigger alert ONLY IF bar is outside of after hours time
alertTrigger = close >= open
alertcondition(alertTrigger and not isAfterHours, title="Alert title", message="Alert message")
Overview
PSMC - Alerts Within Session defines a main trading session along with optional pre-market and after-market periods. The InSession function checks whether the current bar falls inside the session using time functions. Bar color changes based on session status to visually mark the bars. Alert conditions fire only when the bar meets the session criteria, either restricting alerts to within the session or enabling them outside after-hours. Input settings let users customize the exact session times. The script draws bar colors directly on the price chart and demonstrates session-based filtering for alerts. It relies on current bar data only.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Time session
session
0930-1030
session
Pre-market
session
0400-0930
preMarket
After-market
session
1600-2000
afterMarket
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator counts down to a fixed Litecoin halving timestamp in August 2019, using Greenwich Mean Time. It subtracts the current time from that stamp and formats the remaining days, hours, minutes, and seconds. The day, hour, and minute of the target are u
This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-
This indicator identifies and plots key options expiration dates on the price chart. It calculates monthly OpEx (the third Friday of each month), quarterly OpEx (March, June, September, December), and corresponding VIX expiration dates, drawing vertical lines
This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds
The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh
Indicatorv6SMC / ICT / price actionSessions & time
This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in