Strategy · Pine Script v6 · On the chart

TN OR Magnet

by raybird

An opening range strategy for the New York session that records the high and low of a short opening window, then trades retests of that range.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code201
Settings23inputs
LicenceNone stated
Last update2 months ago15 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

Setup A follows drift from the range with a retest, and a conservative Setup B uses breakout plus retest. Filters skip narrow-range days and large gaps, with an optional 200 EMA check. It sizes by risk percentage, uses an ATR stop, limits daily losses and closes positions at a set time.

Details

Published by

raybird on GitHub

Draws

On the price chart

Markets

Indices

Timeframes

M1-M5, M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
TimezonestringAmerica/New_YorktzID
Range Start Hour (ET)int9rangeStartH
Range Start Minuteint30rangeStartM
Range Duration (minutes)int5rangeDuration
Trade Window Start Hour (ET)int9tradeWindowStartH
Trade Window Start Minuteint36tradeWindowStartM
Trade Window End Hour (ET)int11tradeWindowEndH
Trade Window End Minuteint0tradeWindowEndM
Force Close Hour (ET)int16forceCloseH
Force Close Minuteint0forceCloseM
Setup A: Magnet Drift + RetestbooltrueenableSetupA
Setup B: Breakout + Retest (Conservative)boolfalseenableSetupB
Show all 23 settings
SettingTypeDefaultVariable
Min Drift from Magnet (%)float0.02minDriftPct
Confluence Min Drift (%)float0.10confMinDriftPct
Skip NR7 DaysbooltrueuseNR7
Skip Large Gap DaysbooltrueuseGapFilter
Gap Threshold (%)float0.5gapThreshold
Require Price Above 200 EMAboolfalseuseEMA200Filter
Risk % (Setup A)float1.0riskPctA
Risk % (Setup B)float0.5riskPctB
ATR Lengthint14atrLen
ATR Stop Multiplierfloat2.0atrMult
Max Losing Trades Per Dayint2maxLossPerDay
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

106 stars

This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status

Strategy v4 Screeners & dashboardsBreakout Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 1St Bar GAP+BkOut Screener v2 by RM
7 stars

This overlay strategy tracks the high and low of a user-defined London session and plots the previous session levels as support and resistance. It flags a break beyond a level when price closes past an ATR buffer, then waits a set number of bars for a retest w

Strategy v5 Sessions & timeSupport & resistance
Updated 3 months ago · None stated GitHub repository of London SR Cleaner WR (TP 0.20)
6 stars

This strategy combines Opening Range Breakout (ORB) mechanics with Inner Circle Trader (ICT) concepts like Fair Value Gaps, Order Blocks, and liquidity grabs. It identifies session opening ranges and generates signals when price breaks out with supporting rela

Strategy v5 BreakoutSMC / ICT / price action
Updated 7 months ago · None stated GitHub repository of Advanced ORB + ICT Strategy
3 stars

This strategy detects Opening Range Breakouts in a specified session. It calculates the high and low of the opening range bar then plots these levels on the price chart and fills the area between them. Candles are colored based on their relation to the ORB hig

Strategy v5 BreakoutSupport & resistance
Updated 5 months ago · None stated GitHub repository of ORB Hooplah Strategy

algo-trade-indian

by akash-yellgetti
1 stars

A strategy-type script for the price chart that marks the high, low and midpoint of the first part of each session, set by start hour and minute inputs, and alerts when price crosses above the high or below the low. It also plots VWAP and a 50-period EMA, pivo

Strategy v5 Sessions & timeSupport & resistance
Updated 2 years ago · None stated GitHub repository of algo-trade-indian
1 stars

A strategy built around the first regular-session candle of the US day in New York time, together with rejection levels collected from wicks formed during pre-market and after-hours sessions. Rejection levels within a tolerance percentage are grouped. Options

Strategy v5 BreakoutSessions & time
Updated 11 months ago · Custom licence GitHub repository of Breakout Strategy - Step by Step

More Sessions & time scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers