You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Known issue in PineForge Codegen 1.9.1: state in per-bar timeframe requests #314
State inside request.security can produce incorrect results when the requested timeframe is chosen per bar, even when both choices are multiples of the chart and feed timeframe.
On BTCUSDT with a 1-hour chart and feed, the following script chooses 120 or 180 minutes. In released 1.9.1, its entry quantities matched TradingView for 126 of 205 entries. In the 120-minute arm, 17 of 96 matched. These are exact joins by entry time.
//@version=6
strategy("Selected timeframe", currency = currency.NONE, initial_capital = 1000000)
// state inside a request whose timeframe (120 or 180 minutes) is chosen each bar
payload() =>
var float saved_v = na
saved_v := nz(saved_v) + close
saved_v
tf_v = close > open ? "120" : "180"
got_v = request.security(syminfo.tickerid, tf_v, payload())
qty_v = 1 + int(got_v / 1000) % 5
if bar_index > 6 and bar_index % 7 == 3
strategy.entry("L", strategy.long, qty = qty_v)
if bar_index > 6 and bar_index % 7 == 5
strategy.close("L")
Workaround: not yet verified.
Fixed in the next release (1.10.0). The measured fix candidate matches all 205 entry quantities for this case. No release date is announced here.
Updated 2026-11-03: this issue first said "the next patch release". The next release is 1.10.0, a minor release.
Fixed by #316, merged on 2026-11-03. State inside a request.security call whose timeframe is chosen per bar now gets one independent copy per selected timeframe. The float recurrence measured in this issue matches TradingView in 205 of 205 entries, where 1.9.1 matched 126. The fix ships in the next release. A requested timeframe that is not a multiple of the chart timeframe is a separate known issue, pineforge-4pass/pineforge-engine#718, and is not changed by this fix.
Activity
luisleo526 commentedon Nov 2, 2026
Fixed by #316, merged on 2026-11-03. State inside a
request.securitycall whose timeframe is chosen per bar now gets one independent copy per selected timeframe. The float recurrence measured in this issue matches TradingView in 205 of 205 entries, where 1.9.1 matched 126. The fix ships in the next release. A requested timeframe that is not a multiple of the chart timeframe is a separate known issue, pineforge-4pass/pineforge-engine#718, and is not changed by this fix.luisleo526 commentedon Nov 3, 2026
This fix is released in v1.10.0: https://github.com/pineforge-4pass/pineforge-codegen-oss/releases/tag/v1.10.0