Skip to content

request.security() lookahead_off HTF60 alignment differs on partial session candles #63

@cald3ra

Description

@cald3ra

Describe the bug

PyneCore's historical request.security() alignment differs from TradingView
for native 60-minute candles on a 30-minute chart when the exchange session
contains partial hourly candles before non-trading gaps.

This report contains only synthetic data and a minimal indicator. No
proprietary strategy or real market data is included.

The isolated expression is:

midLineHTF = request.security(
    syminfo.tickerid,
    "60",
    (ta.highest(high, 1) + ta.lowest(low, 1)) / 2.0,
    lookahead=barmerge.lookahead_off)

To Reproduce

Extract the attached PyneCore_HTF60_Public_Repro.zip.
Run python generate_native_60.py.
Convert SYNTH_SESSION_30.csv and SYNTH_SESSION_60.csv using the commands in README.md.
Run minimal_htf60_alignment.py with the native 60-minute file supplied through --security.
Compare the plotted midpoint timestamp-by-timestamp with TradingView's output from minimal_htf60_alignment.pine.
Pay particular attention to single-bar native hourly candles immediately before the midday and overnight session gaps.
Expected behavior

PyneCore should expose each finalized native 60-minute value on the same
30-minute historical bar as TradingView's
request.security(..., lookahead_off).

The mapping should be deterministic for normal hourly candles, partial hourly
candles, session gaps, holidays, and shortened sessions.

Screenshots

The reproduction ZIP contains the generated PyneCore plot CSV. A TradingView
Data Window or exported plot comparison can be added if required.

Environment

PyneCore branch: main
Package: pynesys-pynecore 6.4.9
OS: Windows 11
Python: 3.12.13
Execution: PyneCore CLI
Chart timeframe: 30 minutes
Requested timeframe: 60 minutes
lookahead: barmerge.lookahead_off
Additional context

Using fixed HTF open + 60 minutes, next-native-bar timing, and last available
chart-bar timing produces different results around partial hourly candles.

Please confirm the intended PyneCore behavior and whether session-aware native
HTF synchronization is supported.

[PyneCore_HTF60_Public_Repro.zip](https://github.com/user-attachments/files/28711563/PyneCore_HTF60_Public_Repro.zip)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions