An overlay indicator that builds support and resistance rectangles from pivots found inside a morning window in Philippine time, by default 06:00 to 07:30.
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
177 lines of Pine Script v6 from pinescript/indicators/ntouch_zones.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
ntouch_zones.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// NTouch Zones — session-anchored support/resistance rectangles (PHT 06:00-07:30)
//@version=6
indicator("NTouch Zones", "NTZ", overlay=true, max_boxes_count=500)
// ============================================================
// INPUTS
// ============================================================
grpWindow = "Zone Window (PHT)"
winStartH = input.int(6, "Window Start Hour (PHT)", minval=0, maxval=23, group=grpWindow)
winEndH = input.int(7, "Window End Hour (PHT)", minval=0, maxval=23, group=grpWindow)
winEndM = input.int(30, "Window End Minute (PHT)", minval=0, maxval=59, group=grpWindow)
grpZone = "Zone Settings"
touchReq = input.int(2, "Touches Required", minval=2, maxval=10, group=grpZone)
atrLen = input.int(14, "ATR Length", minval=1, maxval=100, group=grpZone)
atrMult = input.float(0.25, "ATR Half-Thickness Mult", minval=0.01, maxval=5.0, step=0.01, group=grpZone)
grpColors = "Colors"
resColor = input.color(color.red, "Resistance Color", group=grpColors)
supColor = input.color(color.green, "Support Color", group=grpColors)
zoneTransp = input.int(80, "Zone Transparency", minval=0, maxval=99, group=grpColors)
// ============================================================
// TIME HELPERS (PHT = Asia/Manila, UTC+8, no DST)
// ============================================================
h = hour(time, "Asia/Manila")
m = minute(time, "Asia/Manila")
// 06:00 - 07:30 zone detection window
inZoneWindow = (h == winStartH) or (h == winEndH and m < winEndM)
// Only true when window end hour > start hour by exactly 1; generalised:
// We handle the canonical 06:00-07:30 case; start of window = hour == winStartH (full hour)
// plus any minute of winEndH before winEndM.
// Window start edge: fires on the very first bar of 06:00
windowStart = inZoneWindow and not inZoneWindow[1]
// Before noon — used to keep extending confirmed zone boxes
beforeNoon = h < 12
// Session-active flag: TRUE from the window start until noon of the SAME day.
// Gating the projection on this (instead of beforeNoon alone) prevents the
// prior day's zones from being re-extended during 00:00-06:00 the next day,
// before the daily array reset fires at the 06:00 window start.
var bool sessionActive = false
if windowStart
sessionActive := true
if not beforeNoon
sessionActive := false
// ============================================================
// ATR (needed each bar; referenced in clustering & box sizing)
// ============================================================
atr = ta.atr(atrLen)
tol = atrMult * atr // cluster tolerance = zone half-thickness
// ============================================================
// PIVOT DETECTION
// Pivots confirm 2 bars late, but the price returned is correct.
// We only count pivots whose *pivot bar* fell inside inZoneWindow.
// Because pivots are confirmed 2 bars later, we check inZoneWindow[2].
// ============================================================
pivHigh = ta.pivothigh(2, 2) // resistance pivot
pivLow = ta.pivotlow(2, 2) // support pivot
// Was the pivot bar itself inside the zone window?
pivInWindow = inZoneWindow[2]
// ============================================================
// LEVEL TRACKING ARRAYS (4 parallel arrays per type)
// Each index represents one discovered price cluster.
// ============================================================
var float[] resPrice = array.new<float>() // running avg price of cluster
var int[] resTouches= array.new<int>() // touch count
var bool[] resConf = array.new<bool>() // confirmed (box drawn)?
var box[] resBoxes = array.new<box>() // box handle (na until confirmed)
var float[] supPrice = array.new<float>()
var int[] supTouches= array.new<int>()
var bool[] supConf = array.new<bool>()
var box[] supBoxes = array.new<box>()
// ============================================================
// DAILY RESET — on the first bar of the zone window each day
// Prior-day boxes remain frozen on the chart; we only clear
// the tracking arrays so the new day starts fresh.
// ============================================================
if windowStart
array.clear(resPrice)
array.clear(resTouches)
array.clear(resConf)
array.clear(resBoxes)
array.clear(supPrice)
array.clear(supTouches)
array.clear(supConf)
array.clear(supBoxes)
// ============================================================
// HELPER: process a new pivot price p into a set of level arrays.
// Returns true if a new box was created (needed nowhere externally,
// but kept for clarity).
// ============================================================
processLevel(float p, float[] prices, int[] counts, bool[] confirmed, box[] boxes, bool isRes) =>
found = false
sz = array.size(prices)
// Search existing clusters for one within tolerance.
// Guarded by sz > 0 so an empty array never produces "for 0 to -1"
// (which can index a size-0 array and throw at runtime).
if sz > 0
for i = 0 to sz - 1
lvl = array.get(prices, i)
if math.abs(lvl - p) <= tol
// Found a matching cluster — update running average, increment count
newCount = array.get(counts, i) + 1
// Running average of price (equally weighted)
newAvg = (lvl * (newCount - 1) + p) / newCount
array.set(prices, i, newAvg)
array.set(counts, i, newCount)
// Confirm the zone when touch threshold is first met
if newCount >= touchReq and not array.get(confirmed, i)
array.set(confirmed, i, true)
halfW = atrMult * atr
zTop = newAvg + halfW
zBot = newAvg - halfW
fillCol = color.new(isRes ? resColor : supColor, zoneTransp)
b = box.new(
left = bar_index,
right = bar_index,
top = zTop,
bottom = zBot,
bgcolor = fillCol,
border_color = na)
array.set(boxes, i, b)
found := true
break
// No existing cluster — push a new one (unconfirmed, no box yet)
if not found
array.push(prices, p)
array.push(counts, 1)
array.push(confirmed, false)
array.push(boxes, na)
// ============================================================
// PROCESS PIVOTS (only count when pivot bar was in window)
// ============================================================
if not na(pivHigh) and pivInWindow
processLevel(pivHigh, resPrice, resTouches, resConf, resBoxes, true)
if not na(pivLow) and pivInWindow
processLevel(pivLow, supPrice, supTouches, supConf, supBoxes, false)
// ============================================================
// PROJECT CONFIRMED ZONES — extend box right edge every bar
// while we are still before noon. After noon, stop (freeze).
// ============================================================
if sessionActive
// Resistance boxes
rSz = array.size(resBoxes)
if rSz > 0
for i = 0 to rSz - 1
b = array.get(resBoxes, i)
if not na(b) and array.get(resConf, i)
box.set_right(b, bar_index)
// Support boxes
sSz = array.size(supBoxes)
if sSz > 0
for i = 0 to sSz - 1
b = array.get(supBoxes, i)
if not na(b) and array.get(supConf, i)
box.set_right(b, bar_index)
Overview
Pivot highs and lows that cluster within a tolerance based on a fraction of the ATR become a zone once they reach the required touch count. Zones are drawn as shaded boxes, red for resistance and green for support, and are projected forward until noon. Window times, touches, ATR settings, colours and transparency are adjustable. Pivots confirm two bars late.
Support and resistance zones from clustered pivots
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Window Start Hour (PHT)
int
6
winStartH
Window End Hour (PHT)
int
7
winEndH
Window End Minute (PHT)
int
30
winEndM
Touches Required
int
2
touchReq
ATR Length
int
14
atrLen
ATR Half-Thickness Mult
float
0.25
atrMult
Resistance Color
color
color.red
resColor
Support Color
color
color.green
supColor
Zone Transparency
int
80
zoneTransp
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 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 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
This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow
This indicator plots reference levels and session markers directly on the price chart. It calculates and draws lines for the daily open, weekly open, monthly open, previous day OHLC, and previous week extremes, along with a selectable day-of-week range and ini