ProRealCode - Trading & Coding with ProRealTime™
//@version=6
indicator(“TRADERXMOM Time-Based Levels”, overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=100)
// ── Settings
lblSize = input.string(“small”, “Label size”, options=[“tiny”,”small”,”normal”,”large”,”huge”], group=”Settings”)
lineWid = input.int(1, “Line width”, minval=1, maxval=4, group=”Settings”)
lineStyle = input.string(“Solid”, “Line style”, options=[“Solid”,”Dashed”,”Dotted”], group=”Settings”)
// ── Previous Day
showPDH = input.bool(true, “Prev Day High”, group=”Previous Day”)
showPDL = input.bool(true, “Prev Day Low”, group=”Previous Day”)
clPDH = input.color(color.new(color.yellow, 0), “PDH color”, group=”Previous Day”)
clPDL = input.color(color.new(color.yellow, 0), “PDL color”, group=”Previous Day”)
// ── Daily Open
showDOpen = input.bool(true, “Daily Open (6pm NY)”, group=”Daily Open”)
clDOpen = input.color(color.new(color.white, 0), “Open color”, group=”Daily Open”)
// ── Asia
showAsiaH = input.bool(true, “Asia High”, group=”Asia (6pm–12am NY)”)
showAsiaL = input.bool(true, “Asia Low”, group=”Asia (6pm–12am NY)”)
clAsiaH = input.color(color.new(color.purple, 0), “Asia High color”, group=”Asia (6pm–12am NY)”)
clAsiaL = input.color(color.new(color.purple, 0), “Asia Low color”, group=”Asia (6pm–12am NY)”)
bgAsia = input.bool(false, “Highlight session background”, group=”Asia (6pm–12am NY)”)
bgAsiaClr = input.color(color.new(color.purple, 90), “Background color”, group=”Asia (6pm–12am NY)”)
// ── London
showLonH = input.bool(true, “London High”, group=”London (12am–6am NY)”)
showLonL = input.bool(true, “London Low”, group=”London (12am–6am NY)”)
clLonH = input.color(color.new(color.orange, 0), “London High color”, group=”London (12am–6am NY)”)
clLonL = input.color(color.new(color.orange, 0), “London Low color”, group=”London (12am–6am NY)”)
bgLon = input.bool(false, “Highlight session background”, group=”London (12am–6am NY)”)
bgLonClr = input.color(color.new(color.orange, 90), “Background color”, group=”London (12am–6am NY)”)
// ── New York
showNYH = input.bool(true, “New York High”, group=”New York (8:30am–11am NY)”)
showNYL = input.bool(true, “New York Low”, group=”New York (8:30am–11am NY)”)
clNYH = input.color(color.new(color.blue, 0), “NY High color”, group=”New York (8:30am–11am NY)”)
clNYL = input.color(color.new(color.blue, 0), “NY Low color”, group=”New York (8:30am–11am NY)”)
bgNY = input.bool(false, “Highlight session background”, group=”New York (8:30am–11am NY)”)
bgNYClr = input.color(color.new(color.blue, 90), “Background color”, group=”New York (8:30am–11am NY)”)
// ── Custom Sessions
showC1 = input.bool(false, “Custom Session 1″, group=”Custom Session 1”)
c1Sess = input.session(“0930-1045”, “Time window (NY)”, group=”Custom Session 1″)
c1HLabel = input.string(“Custom H”, “High label”, group=”Custom Session 1″)
c1LLabel = input.string(“Custom L”, “Low label”, group=”Custom Session 1″)
c1Color = input.color(color.new(color.teal, 0), “Color”, group=”Custom Session 1″)
bgC1 = input.bool(false, “Highlight session background”, group=”Custom Session 1″)
bgC1Clr = input.color(color.new(color.teal, 90), “Background color”, group=”Custom Session 1″)
showC2 = input.bool(false, “Custom Session 2″, group=”Custom Session 2”)
c2Sess = input.session(“0930-1045”, “Time window (NY)”, group=”Custom Session 2″)
c2HLabel = input.string(“Custom H”, “High label”, group=”Custom Session 2″)
c2LLabel = input.string(“Custom L”, “Low label”, group=”Custom Session 2″)
c2Color = input.color(color.new(color.teal, 0), “Color”, group=”Custom Session 2″)
bgC2 = input.bool(false, “Highlight session background”, group=”Custom Session 2″)
bgC2Clr = input.color(color.new(color.teal, 90), “Background color”, group=”Custom Session 2″)
// ── Helpers
f_style(s) => s == “Dashed” ? line.style_dashed : s == “Dotted” ? line.style_dotted : line.style_solid
f_size(s) => s == “tiny” ? size.tiny : s == “small” ? size.small : s == “normal” ? size.normal : s == “large” ? size.large : size.huge
f_mid(x1, x2) => x1 + math.round((x2 – x1) / 2)
// ── Real OHLC (fixes Heikin Ashi price distortion)
// Force real (non-HA) OHLC — _realTicker bypasses Heikin Ashi transformation
_realTicker = ticker.new(syminfo.prefix, syminfo.ticker, session.regular)
realHigh = request.security(_realTicker, timeframe.period, high, lookahead=barmerge.lookahead_off)
realLow = request.security(_realTicker, timeframe.period, low, lookahead=barmerge.lookahead_off)
realOpen = request.security(_realTicker, timeframe.period, open, lookahead=barmerge.lookahead_off)
// ── PDH/PDL from daily TF (reliable, always available)
// Real (non-HA) daily H/L
pdh = request.security(_realTicker, “D”, high[1], lookahead=barmerge.lookahead_on)
pdl = request.security(_realTicker, “D”, low[1], lookahead=barmerge.lookahead_on)
// ── 6pm NY = Asia session start = futures day open
isAsia = not na(time(timeframe.period, “1800-0000”, “America/New_York”))
// ── Asia
var float wAsiaH = na
var float wAsiaL = na
var int wAsiaHBar = na
var int wAsiaLBar = na
var float asiaH = na
var float asiaL = na
var int asiaHBar = na
var int asiaLBar = na
var line asiaHLn = na
var line asiaLLn = na
var label asiaHLb = na
var label asiaLLb = na
var bool asiaHDone = false
var bool asiaLDone = false
if isAsia and not isAsia[1]
wAsiaH := realHigh
wAsiaL := realLow
wAsiaHBar := bar_index
wAsiaLBar := bar_index
else if isAsia
if realHigh > nz(wAsiaH, realHigh)
wAsiaH := realHigh
wAsiaHBar := bar_index
if realLow < nz(wAsiaL, realLow)
wAsiaL := realLow
wAsiaLBar := bar_index
if not isAsia and isAsia[1]
asiaH := wAsiaH
asiaL := wAsiaL
asiaHBar := wAsiaHBar
asiaLBar := wAsiaLBar
line.delete(asiaHLn)
label.delete(asiaHLb)
line.delete(asiaLLn)
label.delete(asiaLLb)
asiaHLn := na
asiaLLn := na
asiaHDone := false
asiaLDone := false
if showAsiaH and not na(asiaH)
if na(asiaHLn)
asiaHLn := line.new(asiaHBar, asiaH, bar_index, asiaH, color=clAsiaH, width=lineWid, style=f_style(lineStyle))
asiaHLb := label.new(f_mid(asiaHBar, bar_index), asiaH, “Asia High”, color=color.new(color.black,100), textcolor=clAsiaH, style=label.style_label_down, size=f_size(lblSize))
if not asiaHDone
line.set_x2(asiaHLn, bar_index)
label.set_x(asiaHLb, f_mid(asiaHBar, bar_index))
if realHigh >= asiaH and realLow <= asiaH
asiaHDone := true
if showAsiaL and not na(asiaL)
if na(asiaLLn)
asiaLLn := line.new(asiaLBar, asiaL, bar_index, asiaL, color=clAsiaL, width=lineWid, style=f_style(lineStyle))
asiaLLb := label.new(f_mid(asiaLBar, bar_index), asiaL, “Asia Low”, color=color.new(color.black,100), textcolor=clAsiaL, style=label.style_label_down, size=f_size(lblSize))
if not asiaLDone
line.set_x2(asiaLLn, bar_index)
label.set_x(asiaLLb, f_mid(asiaLBar, bar_index))
if realHigh >= asiaL and realLow <= asiaL
asiaLDone := true
// ── London
isLondon = not na(time(timeframe.period, “0000-0600”, “America/New_York”))
var float wLonH = na
var float wLonL = na
var int wLonHBar = na
var int wLonLBar = na
var float lonH = na
var float lonL = na
var int lonHBar = na
var int lonLBar = na
var line lonHLn = na
var line lonLLn = na
var label lonHLb = na
var label lonLLb = na
var bool lonHDone = false
var bool lonLDone = false
if isLondon and not isLondon[1]
wLonH := realHigh
wLonL := realLow
wLonHBar := bar_index
wLonLBar := bar_index
else if isLondon
if realHigh > nz(wLonH, realHigh)
wLonH := realHigh
wLonHBar := bar_index
if realLow < nz(wLonL, realLow)
wLonL := realLow
wLonLBar := bar_index
if not isLondon and isLondon[1]
lonH := wLonH
lonL := wLonL
lonHBar := wLonHBar
lonLBar := wLonLBar
line.delete(lonHLn)
label.delete(lonHLb)
line.delete(lonLLn)
label.delete(lonLLb)
lonHLn := na
lonLLn := na
lonHDone := false
lonLDone := false
if showLonH and not na(lonH)
if na(lonHLn)
lonHLn := line.new(lonHBar, lonH, bar_index, lonH, color=clLonH, width=lineWid, style=f_style(lineStyle))
lonHLb := label.new(f_mid(lonHBar, bar_index), lonH, “London High”, color=color.new(color.black,100), textcolor=clLonH, style=label.style_label_down, size=f_size(lblSize))
if not lonHDone
line.set_x2(lonHLn, bar_index)
label.set_x(lonHLb, f_mid(lonHBar, bar_index))
if realHigh >= lonH and realLow <= lonH
lonHDone := true
if showLonL and not na(lonL)
if na(lonLLn)
lonLLn := line.new(lonLBar, lonL, bar_index, lonL, color=clLonL, width=lineWid, style=f_style(lineStyle))
lonLLb := label.new(f_mid(lonLBar, bar_index), lonL, “London Low”, color=color.new(color.black,100), textcolor=clLonL, style=label.style_label_down, size=f_size(lblSize))
if not lonLDone
line.set_x2(lonLLn, bar_index)
label.set_x(lonLLb, f_mid(lonLBar, bar_index))
if realHigh >= lonL and realLow <= lonL
lonLDone := true
// ── New York
isNY = not na(time(timeframe.period, “0830-1100”, “America/New_York”))
var float wNYH = na
var float wNYL = na
var int wNYHBar = na
var int wNYLBar = na
var float nyH = na
var float nyL = na
var int nyHBar = na
var int nyLBar = na
var line nyHLn = na
var line nyLLn = na
var label nyHLb = na
var label nyLLb = na
var bool nyHDone = false
var bool nyLDone = false
if isNY and not isNY[1]
wNYH := realHigh
wNYL := realLow
wNYHBar := bar_index
wNYLBar := bar_index
else if isNY
if realHigh > nz(wNYH, realHigh)
wNYH := realHigh
wNYHBar := bar_index
if realLow < nz(wNYL, realLow)
wNYL := realLow
wNYLBar := bar_index
if not isNY and isNY[1]
nyH := wNYH
nyL := wNYL
nyHBar := wNYHBar
nyLBar := wNYLBar
line.delete(nyHLn)
label.delete(nyHLb)
line.delete(nyLLn)
label.delete(nyLLb)
nyHLn := na
nyLLn := na
nyHDone := false
nyLDone := false
if showNYH and not na(nyH)
if na(nyHLn)
nyHLn := line.new(nyHBar, nyH, bar_index, nyH, color=clNYH, width=lineWid, style=f_style(lineStyle))
nyHLb := label.new(f_mid(nyHBar, bar_index), nyH, “NY High”, color=color.new(color.black,100), textcolor=clNYH, style=label.style_label_down, size=f_size(lblSize))
if not nyHDone
line.set_x2(nyHLn, bar_index)
label.set_x(nyHLb, f_mid(nyHBar, bar_index))
if realHigh >= nyH and realLow <= nyH
nyHDone := true
if showNYL and not na(nyL)
if na(nyLLn)
nyLLn := line.new(nyLBar, nyL, bar_index, nyL, color=clNYL, width=lineWid, style=f_style(lineStyle))
nyLLb := label.new(f_mid(nyLBar, bar_index), nyL, “NY Low”, color=color.new(color.black,100), textcolor=clNYL, style=label.style_label_down, size=f_size(lblSize))
if not nyLDone
line.set_x2(nyLLn, bar_index)
label.set_x(nyLLb, f_mid(nyLBar, bar_index))
if realHigh >= nyL and realLow <= nyL
nyLDone := true
// ── PDH — drawn at 6pm, mitigatable
var line pdhLn = na
var label pdhLb = na
var bool pdhDone = false
if isAsia and not isAsia[1] and showPDH and not na(pdh)
line.delete(pdhLn)
label.delete(pdhLb)
pdhLn := line.new(bar_index, pdh, bar_index, pdh, color=clPDH, width=lineWid, style=f_style(lineStyle))
pdhLb := label.new(bar_index, pdh, “PDH”, color=color.new(color.black,100), textcolor=clPDH, style=label.style_label_down, size=f_size(lblSize))
pdhDone := false
if showPDH and not na(pdhLn) and not pdhDone
line.set_x2(pdhLn, bar_index)
label.set_x(pdhLb, f_mid(line.get_x1(pdhLn), bar_index))
if realHigh >= pdh and realLow <= pdh
pdhDone := true
// ── PDL — drawn at 6pm, mitigatable
var line pdlLn = na
var label pdlLb = na
var bool pdlDone = false
if isAsia and not isAsia[1] and showPDL and not na(pdl)
line.delete(pdlLn)
label.delete(pdlLb)
pdlLn := line.new(bar_index, pdl, bar_index, pdl, color=clPDL, width=lineWid, style=f_style(lineStyle))
pdlLb := label.new(bar_index, pdl, “PDL”, color=color.new(color.black,100), textcolor=clPDL, style=label.style_label_down, size=f_size(lblSize))
pdlDone := false
if showPDL and not na(pdlLn) and not pdlDone
line.set_x2(pdlLn, bar_index)
label.set_x(pdlLb, f_mid(line.get_x1(pdlLn), bar_index))
if realHigh >= pdl and realLow <= pdl
pdlDone := true
// ── Daily Open — drawn at 6pm, extends every bar, never mitigates
var line dopLn = na
var label dopLb = na
if isAsia and not isAsia[1] and showDOpen
line.delete(dopLn)
label.delete(dopLb)
dopLn := line.new(bar_index, realOpen, bar_index, realOpen, color=clDOpen, width=lineWid, style=f_style(lineStyle))
dopLb := label.new(bar_index, realOpen, “Daily Open”, color=color.new(color.black,100), textcolor=clDOpen, style=label.style_label_down, size=f_size(lblSize))
if showDOpen and not na(dopLn)
line.set_x2(dopLn, bar_index)
label.set_x(dopLb, bar_index)
// ── Custom Session 1
var float wC1H = na
var float wC1L = na
var int wC1HBar = na
var int wC1LBar = na
var float c1H = na
var float c1L = na
var int c1HBar = na
var int c1LBar = na
var line c1HLn = na
var line c1LLn = na
var label c1HLb = na
var label c1LLb = na
var bool c1HDone = false
var bool c1LDone = false
isC1 = showC1 and not na(time(timeframe.period, c1Sess, “America/New_York”))
if isC1 and not isC1[1]
wC1H := realHigh
wC1L := realLow
wC1HBar := bar_index
wC1LBar := bar_index
else if isC1
if realHigh > nz(wC1H, realHigh)
wC1H := realHigh
wC1HBar := bar_index
if realLow < nz(wC1L, realLow)
wC1L := realLow
wC1LBar := bar_index
if not isC1 and isC1[1]
c1H := wC1H
c1L := wC1L
c1HBar := wC1HBar
c1LBar := wC1LBar
line.delete(c1HLn)
label.delete(c1HLb)
line.delete(c1LLn)
label.delete(c1LLb)
c1HLn := na
c1LLn := na
c1HDone := false
c1LDone := false
if showC1 and not na(c1H)
if na(c1HLn)
c1HLn := line.new(c1HBar, c1H, bar_index, c1H, color=c1Color, width=lineWid, style=f_style(lineStyle))
c1HLb := label.new(f_mid(c1HBar, bar_index), c1H, c1HLabel, color=color.new(color.black,100), textcolor=c1Color, style=label.style_label_down, size=f_size(lblSize))
if not c1HDone
line.set_x2(c1HLn, bar_index)
label.set_x(c1HLb, f_mid(c1HBar, bar_index))
if realHigh >= c1H and realLow <= c1H
c1HDone := true
if showC1 and not na(c1L)
if na(c1LLn)
c1LLn := line.new(c1LBar, c1L, bar_index, c1L, color=c1Color, width=lineWid, style=f_style(lineStyle))
c1LLb := label.new(f_mid(c1LBar, bar_index), c1L, c1LLabel, color=color.new(color.black,100), textcolor=c1Color, style=label.style_label_down, size=f_size(lblSize))
if not c1LDone
line.set_x2(c1LLn, bar_index)
label.set_x(c1LLb, f_mid(c1LBar, bar_index))
if realHigh >= c1L and realLow <= c1L
c1LDone := true
// ── Custom Session 2
var float wC2H = na
var float wC2L = na
var int wC2HBar = na
var int wC2LBar = na
var float c2H = na
var float c2L = na
var int c2HBar = na
var int c2LBar = na
var line c2HLn = na
var line c2LLn = na
var label c2HLb = na
var label c2LLb = na
var bool c2HDone = false
var bool c2LDone = false
isC2 = showC2 and not na(time(timeframe.period, c2Sess, “America/New_York”))
if isC2 and not isC2[1]
wC2H := realHigh
wC2L := realLow
wC2HBar := bar_index
wC2LBar := bar_index
else if isC2
if realHigh > nz(wC2H, realHigh)
wC2H := realHigh
wC2HBar := bar_index
if realLow < nz(wC2L, realLow)
wC2L := realLow
wC2LBar := bar_index
if not isC2 and isC2[1]
c2H := wC2H
c2L := wC2L
c2HBar := wC2HBar
c2LBar := wC2LBar
line.delete(c2HLn)
label.delete(c2HLb)
line.delete(c2LLn)
label.delete(c2LLb)
c2HLn := na
c2LLn := na
c2HDone := false
c2LDone := false
if showC2 and not na(c2H)
if na(c2HLn)
c2HLn := line.new(c2HBar, c2H, bar_index, c2H, color=c2Color, width=lineWid, style=f_style(lineStyle))
c2HLb := label.new(f_mid(c2HBar, bar_index), c2H, c2HLabel, color=color.new(color.black,100), textcolor=c2Color, style=label.style_label_down, size=f_size(lblSize))
if not c2HDone
line.set_x2(c2HLn, bar_index)
label.set_x(c2HLb, f_mid(c2HBar, bar_index))
if realHigh >= c2H and realLow <= c2H
c2HDone := true
if showC2 and not na(c2L)
if na(c2LLn)
c2LLn := line.new(c2LBar, c2L, bar_index, c2L, color=c2Color, width=lineWid, style=f_style(lineStyle))
c2LLb := label.new(f_mid(c2LBar, bar_index), c2L, c2LLabel, color=color.new(color.black,100), textcolor=c2Color, style=label.style_label_down, size=f_size(lblSize))
if not c2LDone
line.set_x2(c2LLn, bar_index)
label.set_x(c2LLb, f_mid(c2LBar, bar_index))
if realHigh >= c2L and realLow <= c2L
c2LDone := true
// ── Session Background Highlights
bgcolor(bgAsia and isAsia ? bgAsiaClr : na, title=”Asia Session BG”)
bgcolor(bgLon and isLondon ? bgLonClr : na, title=”London Session BG”)
bgcolor(bgNY and isNY ? bgNYClr : na, title=”New York Session BG”)
bgcolor(bgC1 and isC1 ? bgC1Clr : na, title=”Custom Session 1 BG”)
bgcolor(bgC2 and isC2 ? bgC2Clr : na, title=”Custom Session 2 BG”)
But not over here through PRT.
Yes I meant if anyone can do something alike in PRC. Maybe with the lines extended. Quite useful to see the difference between regular and Globex sessions, so as the continental switch hours. TIA
DEFPARAM DrawOnLastBarOnly = True
//------------------- SESSION TIMES (New York time) -------------------
ONCE AsianStart = 200000 // 8:00pm NY
ONCE AsianEnd = 020000 // 2:00am NY (next day)
ONCE LondonStart = 030000 // 3:00am NY
ONCE LondonEnd = 070000 // 7:00am NY
ONCE NewYorkStart = 080000 // 8:00am NY
ONCE NewYorkEnd = 120000 // 12:00pm NY
//------------------- STATE VARIABLES -------------------
ONCE AsianActive = 0
ONCE AsianHH = 0
ONCE AsianLL = 999999
ONCE AsianClose = 0
ONCE LondonActive = 0
ONCE LondonHH = 0
ONCE LondonLL = 999999
ONCE LondonClose = 0
ONCE NYActive = 0
ONCE NYHH = 0
ONCE NYLL = 999999
ONCE NYClose = 0
//=================== ASIAN SESSION (Burnt Orange) ===================
IF (time > AsianStart) OR (time <= AsianEnd) THEN
IF AsianActive = 0 THEN
AsianActive = 1
AsianHH = high
AsianLL = low
AsianClose = close
ELSE
AsianHH = max(AsianHH, high)
AsianLL = min(AsianLL, low)
AsianClose = close // update to current close while session is active
ENDIF
ELSE
IF AsianActive = 1 THEN
// Session just ended → save final values (they will be used for permanent lines)
AsianActive = 0
ENDIF
ENDIF
// Draw extended horizontal lines for Asian session (High, Low, Close)
DRAWHLINE(AsianHH) coloured(204,85,0,255) // Burnt Orange - High
DRAWHLINE(AsianLL) coloured(204,85,0,255) // Burnt Orange - Low
DRAWHLINE(AsianClose) coloured(204,85,0,180) STYLE(DottedLine) // Close - slightly transparent + dotted
//=================== LONDON SESSION (Green) ===================
IF (time > LondonStart) AND (time <= LondonEnd) THEN
IF LondonActive = 0 THEN
LondonActive = 1
LondonHH = high
LondonLL = low
LondonClose = close
ELSE
LondonHH = max(LondonHH, high)
LondonLL = min(LondonLL, low)
LondonClose = close
ENDIF
ELSE
IF LondonActive = 1 THEN
LondonActive = 0
ENDIF
ENDIF
DRAWHLINE(LondonHH) coloured(0,150,0,255) // Green - High
DRAWHLINE(LondonLL) coloured(0,150,0,255) // Green - Low
DRAWHLINE(LondonClose) coloured(0,150,0,180) STYLE(DottedLine)
//=================== NEW YORK SESSION (Blue) ===================
IF (time > NewYorkStart) AND (time <= NewYorkEnd) THEN
IF NYActive = 0 THEN
NYActive = 1
NYHH = high
NYLL = low
NYClose = close
ELSE
NYHH = max(NYHH, high)
NYLL = min(NYLL, low)
NYClose = close
ENDIF
ELSE
IF NYActive = 1 THEN
NYActive = 0
ENDIF
ENDIF
DRAWHLINE(NYHH) coloured(0,0,200,255) // Blue - High
DRAWHLINE(NYLL) coloured(0,0,200,255) // Blue - Low
DRAWHLINE(NYClose) coloured(0,0,200,180) STYLE(DottedLine)
RETURN
Plots key intraday reference levels: previous day high/low, the daily
This topic contains 3 replies,
has 2 voices, and was last updated by Ziggy
1 week ago.
| Forum: | ProBuilder: Indicators & Custom Tools |
| Language: | English |
| Started: | 07/17/2026 |
| Status: | Active |
| Attachments: | No files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.