1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
35 lines of Pine Script v6 from scripts/session-filter.pine.txt, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.
session-filter.pine.txt
//@version=6
indicator("Session Filter", overlay = true)
// 1. Settings: which hours you want to trade
sessionTime = input.session("0800-1600", "Trading session")
sessionZone = input.string("Europe/London", "Timezone")
fastLen = input.int(9, "Fast average")
slowLen = input.int(21, "Slow average")
// 2. Are we inside the session right now?
inSession = not na(time(timeframe.period, sessionTime, sessionZone))
// 3. Shade the background during the session
bgcolor(inSession ? color.new(color.blue, 92) : na)
// 4. The signal we want to filter
fast = ta.ema(close, fastLen)
slow = ta.ema(close, slowLen)
plot(fast, "Fast", color.aqua)
plot(slow, "Slow", color.orange)
// 5. The raw crossover, at any time of day
rawBuy = ta.crossover(fast, slow)
// 6. The same signal, but only inside your session
buySignal = rawBuy and inSession
// 7. Show both, so you can see what the filter removed
plotshape(rawBuy and not inSession, "Skipped", shape.xcross,
location.belowbar, color.gray, size = size.tiny)
plotshape(buySignal, "Buy", shape.triangleup, location.belowbar,
color.green, size = size.small)
// 8. Alert only for the filtered signal
alertcondition(buySignal, "Buy in session", "{{ticker}} buy inside session")
Overview
Session Filter marks a buy when the fast average crosses above the slow average only during a user-defined trading session, and it marks crossovers outside that window as skipped. A light blue background shades bars inside the session. The session hours, timezone, and both average lengths are adjustable. An alert fires only for the filtered buy. There is no sell signal or exit rule.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Trading session
session
0800-1600
sessionTime
Timezone
string
Europe/London
sessionZone
Fast average
int
9
fastLen
Slow average
int
21
slowLen
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.
Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba
Market Monitor - 15m is a directional bias chart overlay designed for 15-minute intraday chart analysis. It calculates a triple exponential moving average ribbon with EMA cloud shading, session VWAP with multiplier bands, prior day levels, a 30-minute opening
This overlay indicator evaluates trade setups on gold and intraday charts using a multi-layered filtering system. It combines fast, slow, and trend EMAs with session time filters, VWAP direction, higher-timeframe trend alignment, and ADX trend strength. It tra
This indicator detects Beat the Market Maker (BTMM) second leg confirmation patterns directly on the price chart. It evaluates first leg size in pips, sets maximum pullback thresholds, and requires multi-bar confirmation for continuation setups. Trend bias is
This indicator identifies pivot highs and lows using a swing lookback period and connects them with trendlines on the price chart. It generates long and short entry signals when price moves through predefined percentage thresholds in three steps for buy and se
Calculates short and long simple moving averages to identify crossover signals within a specified UTC time window. When a crossover occurs during valid trading hours, BUY or SELL labels are drawn on the price chart. If price subsequently moves 100 points in th