Iván González

Session Levels & Key Opens

Studio Only
Category: Indicators By: Iván González Created: December 3, 2026, 1:14 PM
December 3, 2026, 1:14 PM
Indicators
0 Comments
ProRealCode Script
Session Levels & Key Opens

Introduction

 

Intraday traders of index and commodity futures watch the same handful of prices every morning: where Asia and London topped and bottomed, where the New York sessions put their extremes, the opens that reset the day, and yesterday’s, last week’s and last month’s high and low. Session Levels & Key Opens by TraderK puts all of them on the chart in one go and keeps them clean: a high or low line starts at the very candle that made the extreme and runs right until price takes it out, and then it stops there.

Theory Behind the Indicator

 

Session highs and lows. Five sessions are tracked: Asia, London, NY AM, NY Lunch and NY PM. While a session is open the indicator follows its highest high and lowest low and remembers the candle of each. When the session closes it draws both levels from those candles.

Sweeps. A high level is swept when a later candle trades above it; a low level when a candle trades below it. With the cut option on, the line ends on the sweeping candle, so what is still running on the right edge of the chart is liquidity that has not been taken yet.

Key opens. Four reference prices that the session traders use as the “fair” anchors of the day: the New York midnight open, the 08:30 New York open (the time of the main US data releases), the new-day open of the futures trading day and the new-week open. Each one is a horizontal line from its candle until the next open of the same kind.

Previous day, week and month. The trading day starts at a configurable time (by default 18:00 New York, the CME 6 pm to 5 pm day). At each new day the previous day’s high and low are drawn from the candles that made them; at the first day of a new week and of a new month, the previous week’s and month’s.

Key Features at a Glance

 

  • Asia, London, NY AM, NY Lunch and NY PM highs and lows, each with its own colour and line style
  • Lines anchored to the actual candle of the extreme, cut on the candle that sweeps them
  • New York midnight, 08:30, new-day and new-week opens
  • Previous day, week and month high and low
  • Adjustable history: today only, 2, 3, 5 or 10 trading days, or everything; the previous week and month levels stay visible for the current week and month
  • Labels at the end of every line
  • Built for intraday charts of 30 minutes or lower; on higher timeframes it only shows a reminder

How to Read the Indicator

 

  • A level that still runs to the last candle has not been swept. Those are the obvious targets for a liquidity run.
  • A line that stops mid-chart was swept on its last candle. Watch what price did next: a quick rejection after the sweep of the Asia or London high is the classic stop run; acceptance above it turns the old high into support.
  • The opens split the day into premium and discount: above the new-day or midnight open price trades at a premium to the day’s anchor, below it at a discount.
  • PDH, PDL, PWH, PWL, PMH and PML are the higher timeframe references. When a session level sits close to one of them, the area matters twice.

Practical Applications

 

  • Plan the New York session around the untouched Asia and London levels and the previous day’s high and low.
  • Use the 08:30 and midnight opens as intraday bias filters: longs above, shorts below.
  • Keep the history short (today plus one day) for a clean screen, and switch to 5 or 10 days to study how the levels were taken.

Indicator Configuration

 

All times are New York times (HHMM). Each bar’s time is converted to New York time with the US summer-time rule, so the defaults hold on any instrument and any exchange, all year round, with no adjustment.

  • General:
  • Trading-day open (default: 1800): the boundary of days, weeks and months
  • History to load (default: 2 days): Today only, 2, 3, 5 or 10 days, or All
  • Cut line when price sweeps the level (default: on)
  • Show labels (default: on) and label size (tiny, small, normal, large)
  • Line width (default: 1, from 1 to 5)
  • Sessions, each on one row with on/off, from, to, colour and style (Solid, Dashed, Dotted):
  • Asia: 20:00 to 00:00
  • London: 02:00 to 05:00
  • NY AM: 09:30 to 11:00
  • NY Lunch: 12:00 to 13:00
  • NY PM: 13:00 to 16:00
  • Key levels, each with on/off, colour and style: midnight open (00:00), 08:30 open, new-day open (18:00), new-week open, and the previous day, week and month high and low

The Code

 

This is the ProRealCode Studio version: paste it into a new ProRealCode Studio tab on ProRealTime Web.

//---------------------------------------------------------------
// PRC_Session Levels
// version = 0
// 03.12.2026
// Iván González @ www.prorealcode.com
// Author: TraderK
// Sharing ProRealTime knowledge
//---------------------------------------------------------------
// Session highs and lows (Asia, London, NY AM, NY Lunch, NY PM), key opens
// (New York midnight, 08:30 New York, new day, new week) and the previous
// day / week / month highs and lows. High/low lines start at the candle that
// made the extreme and run right until price sweeps them. Intraday only
// (30 minutes or lower).
// All times are New York times (HHMM): each bar's UTC
// time is turned into New York time with the US summer-time rule, so they
// hold on any instrument and any exchange, all year round.
//---------------------------------------------------------------
DEFPARAM DRAWONLASTBARONLY = true

// ------------------------------- SETTINGS: GENERAL
input(dayBnd, 1800, "Trading-day open HHMM, New York (day, week and month boundary)", int, group = "General")
input(hist, "2 days", "History to load", string, options = ["Today only", "2 days", "3 days", "5 days", "10 days", "All"], group = "General")
input(cutOnSweep, 1, "Cut line when price sweeps the level", bool, group = "General")
input(showLabels, 1, "Show labels", bool, group = "General")
input(lblSize, "small", "Label size", string, options = ["tiny", "small", "normal", "large"], group = "General")
input(lineWidth, 1, "Line width", int, minval = 1, maxval = 5, group = "General")

// ------------------------------- SETTINGS: SESSIONS (from / to HHMM, New York)
input(asiaOn, 1, "Asia", bool, group = "Sessions", inline = "asia")
input(asiaFrom, 2000, "from", int, group = "Sessions", inline = "asia")
input(asiaTo, 0, "to", int, group = "Sessions", inline = "asia")
input(asiaCol, "#f7c948", "colour", color, group = "Sessions", inline = "asia")
input(asiaSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Sessions", inline = "asia")
input(lonOn, 1, "London", bool, group = "Sessions", inline = "lon")
input(lonFrom, 200, "from", int, group = "Sessions", inline = "lon")
input(lonTo, 500, "to", int, group = "Sessions", inline = "lon")
input(lonCol, "#4895ef", "colour", color, group = "Sessions", inline = "lon")
input(lonSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Sessions", inline = "lon")
input(amOn, 1, "NY AM", bool, group = "Sessions", inline = "am")
input(amFrom, 930, "from", int, group = "Sessions", inline = "am")
input(amTo, 1100, "to", int, group = "Sessions", inline = "am")
input(amCol, "#43aa8b", "colour", color, group = "Sessions", inline = "am")
input(amSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Sessions", inline = "am")
input(luOn, 1, "NY Lunch", bool, group = "Sessions", inline = "lu")
input(luFrom, 1200, "from", int, group = "Sessions", inline = "lu")
input(luTo, 1300, "to", int, group = "Sessions", inline = "lu")
input(luCol, "#9d4edd", "colour", color, group = "Sessions", inline = "lu")
input(luSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Sessions", inline = "lu")
input(pmOn, 1, "NY PM", bool, group = "Sessions", inline = "pm")
input(pmFrom, 1300, "from", int, group = "Sessions", inline = "pm")
input(pmTo, 1600, "to", int, group = "Sessions", inline = "pm")
input(pmCol, "#f3722c", "colour", color, group = "Sessions", inline = "pm")
input(pmSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Sessions", inline = "pm")

// ------------------------------- SETTINGS: KEY LEVELS
input(midOn, 1, "Midnight open (00:00)", bool, group = "Key Levels", inline = "mid")
input(midHM, 0, "at", int, group = "Key Levels", inline = "mid")
input(midCol, "#5d606b", "colour", color, group = "Key Levels", inline = "mid")
input(midSty, "Dashed", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "mid")
input(opOn, 1, "08:30 open", bool, group = "Key Levels", inline = "op")
input(opHM, 830, "at", int, group = "Key Levels", inline = "op")
input(opCol, "#ff5d8f", "colour", color, group = "Key Levels", inline = "op")
input(opSty, "Dashed", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "op")
input(ndOn, 1, "New-day open", bool, group = "Key Levels", inline = "nd")
input(ndHM, 1800, "at", int, group = "Key Levels", inline = "nd")
input(ndCol, "#00bcd4", "colour", color, group = "Key Levels", inline = "nd")
input(ndSty, "Dashed", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "nd")
input(nwOn, 1, "New-week open", bool, group = "Key Levels", inline = "nw")
input(nwCol, "#e040fb", "colour", color, group = "Key Levels", inline = "nw")
input(nwSty, "Dashed", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "nw")
input(pdhOn, 1, "Previous day high", bool, group = "Key Levels", inline = "pdh")
input(pdhCol, "#e63946", "colour", color, group = "Key Levels", inline = "pdh")
input(pdhSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pdh")
input(pdlOn, 1, "Previous day low", bool, group = "Key Levels", inline = "pdl")
input(pdlCol, "#2a9d8f", "colour", color, group = "Key Levels", inline = "pdl")
input(pdlSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pdl")
input(pwhOn, 1, "Previous week high", bool, group = "Key Levels", inline = "pwh")
input(pwhCol, "#e85d04", "colour", color, group = "Key Levels", inline = "pwh")
input(pwhSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pwh")
input(pwlOn, 1, "Previous week low", bool, group = "Key Levels", inline = "pwl")
input(pwlCol, "#faa307", "colour", color, group = "Key Levels", inline = "pwl")
input(pwlSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pwl")
input(pmhOn, 1, "Previous month high", bool, group = "Key Levels", inline = "pmh")
input(pmhCol, "#c1121f", "colour", color, group = "Key Levels", inline = "pmh")
input(pmhSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pmh")
input(pmlOn, 1, "Previous month low", bool, group = "Key Levels", inline = "pml")
input(pmlCol, "#669bbc", "colour", color, group = "Key Levels", inline = "pml")
input(pmlSty, "Solid", "style", string, options = ["Solid", "Dashed", "Dotted"], group = "Key Levels", inline = "pml")

// ------------------------------- CLOCK: every bar in New York time
FUNCTION toMin(hm)
floor(hm / 100) * 60 + (hm MOD 100)
ENDFUNCTION

// Days since 1970-01-01 of a date, and the date of a day number
FUNCTION daysOf(y, m, d)
yy = y - (m <= 2)
era = floor(yy / 400)
yoe = yy - era * 400
mp = m + 9 - 12 * (m > 2)
doy = floor((153 * mp + 2) / 5) + d - 1
era * 146097 + yoe * 365 + floor(yoe / 4) - floor(yoe / 100) + doy - 719468
ENDFUNCTION

FUNCTION dateOf(z)
zz = z + 719468
era = floor(zz / 146097)
doe = zz - era * 146097
yoe = floor((doe - floor(doe / 1460) + floor(doe / 36524) - floor(doe / 146096)) / 365)
doy = doe - (365 * yoe + floor(yoe / 4) - floor(yoe / 100))
mp = floor((5 * doy + 2) / 153)
m = mp + 3 - 12 * (mp >= 10)
RETURN yoe + era * 400 + (m <= 2), m, doy - floor((153 * mp + 2) / 5) + 1
ENDFUNCTION

// New York's offset from UTC at a UTC time: summer time runs from the second
// Sunday of March (07:00 UTC) to the first Sunday of November (06:00 UTC)
FUNCTION nyOffset(s)
(y, m, d) = dateOf(floor(s / 86400))
mar = daysOf(y, 3, 1)
nov = daysOf(y, 11, 1)
dstOn = (mar + (7 - (mar + 4) MOD 7) MOD 7 + 7) * 86400 + 25200
dstOff = (nov + (7 - (nov + 4) MOD 7) MOD 7) * 86400 + 21600
(s >= dstOn AND s < dstOff) - 5
ENDFUNCTION

// The bar's open in New York: minute of the day, weekday (0 = Sunday) and month
nyS = opentimestamp + nyOffset(opentimestamp) * 3600
nyDay = floor(nyS / 86400)
tMin = floor((nyS - nyDay * 86400) / 60)
pM = tMin[1]
nyDow = (nyDay + 4) MOD 7
(nyY, nyMon, nyD) = dateOf(nyDay)
ONCE stepMin = 1440
IF barindex > 0 THEN
stepMin = min(stepMin, (opentimestamp - opentimestamp[1]) / 60)
ENDIF
tooHigh = stepMin > 30
atrL = averagetruerange[14](close)

// trading-day boundary: the clock passes dayBnd between two bars (midnight between them included)
bndMin = toMin(dayBnd)
newDay = barindex > 0 AND ((tMin > pM AND pM < bndMin AND tMin >= bndMin) OR (tMin <= pM AND (pM < bndMin OR tMin >= bndMin)))
// new week: the weekday of a new trading day is not after the previous one; new month: its month changes
ONCE lastDow = -1
ONCE lastMon = -1
newWeek = newDay AND lastDow >= 0 AND nyDow <= lastDow
newMonth = newDay AND lastMon >= 0 AND nyMon <> lastMon
IF newDay THEN
lastDow = nyDow
lastMon = nyMon
ENDIF
ONCE dayIx = 0
ONCE weekIx = 0
ONCE monthIx = 0
dayIx = dayIx + newDay
weekIx = weekIx + newWeek
monthIx = monthIx + newMonth

// ------------------------------- TRACKERS
// Each written call of a function keeps its own memory, so one function
// serves the five sessions and another the day, the week and the month.

// The previous period's high and low, and the bar of each
FUNCTION periodHL(isNew)
IF isNew THEN
qH = cH
qL = cL
qHb = cHb
qLb = cLb
ENDIF
IF isNew OR barindex = 0 OR high > cH THEN
cH = high
cHb = barindex
ENDIF
IF isNew OR barindex = 0 OR low < cL THEN
cL = low
cLb = barindex
ENDIF
RETURN qH, qL, qHb, qLb
ENDFUNCTION

// A session's high and low and their bars; done = 1 on the first bar after it
FUNCTION sessHL(on, s0, e0)
a = toMin(s0)
b = toMin(e0)
IF a < b THEN
inS = on AND tMin >= a AND tMin < b
ELSE
inS = on AND (tMin >= a OR tMin < b)
ENDIF
done = inS = 0 AND wasIn = 1
IF inS AND wasIn = 0 THEN
cH = high
cL = low
cHb = barindex
cLb = barindex
ELSIF inS THEN
IF high > cH THEN
cH = high
cHb = barindex
ENDIF
IF low < cL THEN
cL = low
cLb = barindex
ENDIF
ENDIF
wasIn = inS
RETURN done, cH, cL, cHb, cLb
ENDFUNCTION

// First bar of a one-minute window (an open time)
FUNCTION opensAt(on, hm)
m = toMin(hm)
on AND barindex > 0 AND tMin = m AND pM <> m
ENDFUNCTION

// ------------------------------- LEVEL REGISTER
// One slot per level, indexed by a scalar counter: on the live bar the counter
// is rewound on every tick, so the slot is rewritten, never duplicated.
// kind: 0-4 sessions, 5 PDH, 6 PDL, 7 PWH, 8 PWL, 9 PMH, 10 PML,
// 11 midnight open, 12 08:30 open, 13 new-day open, 14 new-week open
FUNCTION addLvl(slot, on, x, y, hi, kind)
IF on THEN
$lvX[slot] = x
$lvY[slot] = y
$lvHi[slot] = hi
$lvK[slot] = kind
$lvB[slot] = barindex
$lvD[slot] = dayIx
$lvW[slot] = weekIx
$lvM[slot] = monthIx
ENDIF
on
ENDFUNCTION

ONCE nLv = 0
(e, h, l, hb, lb) = sessHL(asiaOn, asiaFrom, asiaTo)
nLv = nLv + addLvl(nLv, e, hb, h, 1, 0)
nLv = nLv + addLvl(nLv, e, lb, l, 0, 0)
(e, h, l, hb, lb) = sessHL(lonOn, lonFrom, lonTo)
nLv = nLv + addLvl(nLv, e, hb, h, 1, 1)
nLv = nLv + addLvl(nLv, e, lb, l, 0, 1)
(e, h, l, hb, lb) = sessHL(amOn, amFrom, amTo)
nLv = nLv + addLvl(nLv, e, hb, h, 1, 2)
nLv = nLv + addLvl(nLv, e, lb, l, 0, 2)
(e, h, l, hb, lb) = sessHL(luOn, luFrom, luTo)
nLv = nLv + addLvl(nLv, e, hb, h, 1, 3)
nLv = nLv + addLvl(nLv, e, lb, l, 0, 3)
(e, h, l, hb, lb) = sessHL(pmOn, pmFrom, pmTo)
nLv = nLv + addLvl(nLv, e, hb, h, 1, 4)
nLv = nLv + addLvl(nLv, e, lb, l, 0, 4)

(ph, pl, phb, plb) = periodHL(newDay)
nLv = nLv + addLvl(nLv, newDay AND dayIx >= 1 AND pdhOn, phb, ph, 1, 5)
nLv = nLv + addLvl(nLv, newDay AND dayIx >= 1 AND pdlOn, plb, pl, 0, 6)
(ph, pl, phb, plb) = periodHL(newWeek)
nLv = nLv + addLvl(nLv, newWeek AND weekIx >= 1 AND pwhOn, phb, ph, 1, 7)
nLv = nLv + addLvl(nLv, newWeek AND weekIx >= 1 AND pwlOn, plb, pl, 0, 8)
(ph, pl, phb, plb) = periodHL(newMonth)
nLv = nLv + addLvl(nLv, newMonth AND monthIx >= 1 AND pmhOn, phb, ph, 1, 9)
nLv = nLv + addLvl(nLv, newMonth AND monthIx >= 1 AND pmlOn, plb, pl, 0, 10)

// opens: kept in the same register (hi = -1), they run until the next open of their kind
nLv = nLv + addLvl(nLv, opensAt(midOn, midHM), barindex, open, -1, 11)
nLv = nLv + addLvl(nLv, opensAt(opOn, opHM), barindex, open, -1, 12)
nLv = nLv + addLvl(nLv, opensAt(ndOn, ndHM), barindex, open, -1, 13)
nLv = nLv + addLvl(nLv, nwOn AND newWeek, barindex, open, -1, 14)

// ------------------------------- DRAWING
// One level: colour, style and name from its kind, then the line and its label
FUNCTION drawLvl(x1, x2, y, kind, hi)
IF kind = 0 THEN
c = asiaCol
s = asiaSty
t = "Asia"
ELSIF kind = 1 THEN
c = lonCol
s = lonSty
t = "London"
ELSIF kind = 2 THEN
c = amCol
s = amSty
t = "NY AM"
ELSIF kind = 3 THEN
c = luCol
s = luSty
t = "NY Lunch"
ELSIF kind = 4 THEN
c = pmCol
s = pmSty
t = "NY PM"
ELSIF kind = 5 THEN
c = pdhCol
s = pdhSty
t = "PDH"
ELSIF kind = 6 THEN
c = pdlCol
s = pdlSty
t = "PDL"
ELSIF kind = 7 THEN
c = pwhCol
s = pwhSty
t = "PWH"
ELSIF kind = 8 THEN
c = pwlCol
s = pwlSty
t = "PWL"
ELSIF kind = 9 THEN
c = pmhCol
s = pmhSty
t = "PMH"
ELSIF kind = 10 THEN
c = pmlCol
s = pmlSty
t = "PML"
ELSIF kind = 11 THEN
c = midCol
s = midSty
t = "00:00"
ELSIF kind = 12 THEN
c = opCol
s = opSty
t = "08:30"
ELSIF kind = 13 THEN
c = ndCol
s = ndSty
t = "NDO"
ELSE
c = nwCol
s = nwSty
t = "NWO"
ENDIF
IF kind <= 4 AND hi = 1 THEN
t = t + " H"
ELSIF kind <= 4 THEN
t = t + " L"
ENDIF
// STYLE() takes the line type as a keyword, not as a variable
IF s = "Dashed" THEN
DRAWSEGMENT(x1, y, x2, y) COLOURED(c) STYLE(dottedline2, lineWidth)
ELSIF s = "Dotted" THEN
DRAWSEGMENT(x1, y, x2, y) COLOURED(c) STYLE(dottedline, lineWidth)
ELSE
DRAWSEGMENT(x1, y, x2, y) COLOURED(c) STYLE(line, lineWidth)
ENDIF
IF showLabels THEN
// high/low: the label ends at the line end, above or below it; open: just past the end
IF hi = -1 THEN
lx = x2 + 1
ly = y
ELSE
lx = x2
ly = y + (2 * hi - 1) * 0.3 * atrL
ENDIF
// the label size is a keyword too
IF hi = -1 AND lblSize = "tiny" THEN
DRAWLABEL(lx, ly, t, none, tiny, left) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF hi = -1 AND lblSize = "normal" THEN
DRAWLABEL(lx, ly, t, none, normal, left) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF hi = -1 AND lblSize = "large" THEN
DRAWLABEL(lx, ly, t, none, large, left) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF hi = -1 THEN
DRAWLABEL(lx, ly, t, none, small, left) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF lblSize = "tiny" THEN
DRAWLABEL(lx, ly, t, none, tiny, right) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF lblSize = "normal" THEN
DRAWLABEL(lx, ly, t, none, normal, right) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSIF lblSize = "large" THEN
DRAWLABEL(lx, ly, t, none, large, right) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ELSE
DRAWLABEL(lx, ly, t, none, small, right) COLOURED(c) FILLCOLOR(0, 0, 0, 0) BORDERCOLOR(0, 0, 0, 0)
ENDIF
ENDIF
1
ENDFUNCTION

$hA[barindex] = high
$lA[barindex] = low

IF islastbarupdate THEN
IF tooHigh THEN
DRAWTEXT("Session Levels: use 30m or lower", -120, 20, SansSerif, Standard, 9) ANCHOR(BOTTOMRIGHT, XSHIFT, YSHIFT) COLOURED(128, 128, 128)
ELSE
IF hist = "Today only" THEN
cutD = dayIx
ELSIF hist = "3 days" THEN
cutD = dayIx - 2
ELSIF hist = "5 days" THEN
cutD = dayIx - 4
ELSIF hist = "10 days" THEN
cutD = dayIx - 9
ELSIF hist = "All" THEN
cutD = -1
ELSE
cutD = dayIx - 1
ENDIF
FOR q = 11 TO 14 DO
$nxB[q] = -1
NEXT
drawn = 0
// newest first: an open line ends where the next open of its kind starts
FOR i = nLv - 1 DOWNTO 0 DO
curK = $lvK[i]
curY = $lvY[i]
x2 = barindex
IF $lvHi[i] = -1 THEN
IF $nxB[curK] >= 0 THEN
x2 = max($lvX[i], $nxB[curK] - 1)
ENDIF
$nxB[curK] = $lvX[i]
ELSIF cutOnSweep THEN
// a high/low line is cut on the first candle that sweeps it
FOR j = $lvB[i] TO barindex DO
IF ($lvHi[i] = 1 AND $hA[j] > curY) OR ($lvHi[i] = 0 AND $lA[j] < curY) THEN
x2 = j
BREAK
ENDIF
NEXT
ENDIF
// previous week/month levels and the week open stay while their period is current
keep = $lvD[i] >= cutD OR ((curK = 7 OR curK = 8 OR curK = 14) AND $lvW[i] = weekIx) OR ((curK = 9 OR curK = 10) AND $lvM[i] = monthIx)
IF keep AND drawn < 500 THEN
drawn = drawn + 1
z = drawLvl($lvX[i], x2, curY, curK, $lvHi[i])
ENDIF
NEXT
ENDIF
ENDIF

RETURN

Original author: TraderK.

No ITF file for this code
A Studio Only code is not imported into ProRealTime™. Copy it and paste it into the ProRealCode Studio editor.
Iván González
Iván González Legend
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

ProRealCode ProRealCode
Loading...