Strategy · Pine Script v6 · On the chart

Session Ismarket NYSE RTH Gate

by pineforge-4pass

A test strategy from a reference corpus that only trades during regular market hours as reported by the session variable.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code16
Settings0inputs
LicenceApache-2.0
Last update6 days ago23 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

16 lines of Pine Script v6 from validation/symbol-specified/AAPL/session-ismarket-nyse-rth-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// TV_RUN_NEEDED: tv_trades.csv missing — capture in TradingView:
//   Symbol: AAPL  TF: 5m  Range: 2024-01-02..2024-03-29
//   Save List of Trades → tv_trades.csv in this directory.

//@version=6
strategy("Session ismarket NYSE RTH gate", overlay=true,
         default_qty_type=strategy.fixed, default_qty_value=1)

// Only trade when inside NYSE regular trading hours (09:30–16:00 ET).
// session.ismarket uses syminfo.session which the validator injects via
// syminfo_overrides → session = "0930-1600".
if session.ismarket
    if ta.crossover(ta.sma(close, 9), ta.sma(close, 21))
        strategy.entry("Long", strategy.long)
    if ta.crossunder(ta.sma(close, 9), ta.sma(close, 21))
        strategy.close("Long")

Overview

Within those hours it buys one unit when a 9-period simple moving average crosses above a 21-period one and closes the long on the opposite cross. There is no stop loss or take profit. It was written for AAPL on a 5-minute chart to check engine session handling and is a code example rather than a tuned system.

Details

Published by

pineforge-4pass on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Moving averages, Sessions & time

Markets

Stocks

Timeframes

M1-M5

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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.

Similar Pine Scripts

This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk

Strategy v5 Volatility & bandsMoving averages
Updated yesterday · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
257 stars

Donald - Test Logic Futures is an overlay strategy designed for intraday futures trading. It combines kernel regression functions with exponential moving averages to evaluate price retracements and entry timing. Trades are filtered by session execution windows

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald - Test Logic Futures

Andean Scalping

by hasnocool
106 stars

Andean Scalping is a Pine Script v5 strategy template designed for backtesting trading signals. It features session and date-range filtering, directional trade toggles for long and short entries, and optional trend filtering tools including higher-timeframe EM

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of Andean Scalping
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 5 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

P404 Smoke

by Musyimi97
16 stars

P404 Smoke is a price-chart strategy that sequences an optional higher-timeframe EMA bias, a liquidity range from recent pivots, a sweep of buy-side or sell-side liquidity, and a market structure shift within a set bar window. Comments state it then looks for

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of P404 Smoke

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers