Skip to content

Limit exits fill only on trade-through; TradingView fills on exact touch (~1% of trades) #177

Description

@dfl3xrs

Summary

Comparing PineForge (release v0.1.19 / engine 0.12.3 / codegen 0.10.1, Docker pineforge-release:latest) trade-for-trade against TradingView Strategy Tester "List of Trades" exports for three futures strategies on ~1.07M 1-minute bars (COMEX micro gold, MGC), parity is 97-98% all-fields-equal. Excellent.

Of the remaining mismatches, every non-roll-day case has the same shape: a strategy.exit(limit=...) target that the bar's high (long) / low (short) reaches exactly to the tick is filled by TradingView and not by PineForge, which then exits later on the stop or the EOD flat. It looks like the limit-fill condition is strict (> / <) where TradingView behaves as >= / <=.

Setup

  • syminfo.json: {"mintick": 0.1, "pointvalue": 10.0, "timezone": "America/New_York", "session": "1800-1700"}
  • PINEFORGE_INPUT_TF=1, PINEFORGE_CHART_TZ=Europe/Stockholm, PINEFORGE_OVERRIDES={"initial_capital":"1000000"}, no magnifier
  • Strategy shape: strategy.entry(..., stop=lvl) then strategy.exit(id, from_entry, stop=ep - r, limit=ep + r); calc_on_every_tick=false, pyramiding=0, process_orders_on_close default.

Four reproducible cases (MGC 1-min, bar timestamps UTC; the bar's extreme equals the limit price exactly)

strategy limit bar (open) bar high/low TradingView PineForge
long 2684.90 2025-01-14 12:22 high 2684.9 filled 12:22 @ 2684.90 not filled; exited later @ 2676.70
long 3553.70 2025-09-02 07:44 high 3553.7 filled 07:44 @ 3553.70 not filled; exited 07:51 @ 3545.50
long 2047.60 2023-12-21 10:18 high 2047.6 filled 10:18 @ 2047.60 not filled; exited 10:29 @ 2045.80
short 2038.20 2024-02-27 20:29 low 2038.2 filled 20:29 @ 2038.20 not filled; EOD exit @ 2039.60

OHLC for the first case: 12:22 2683.9 / 2684.9 / 2683.7 / 2684.8. Entry prices and all other trades in these runs match TradingView to the tick, so this is not a data, timezone or contract-roll offset.

Expected: a limit exit fills when the bar's extreme equals the limit price (TradingView semantics).
Observed: the extreme must exceed the limit price.

Impact: ~1% of trades on these strategies, always in the conservative direction (a missed target becomes a later stop/EOD exit), so PF is slightly understated - e.g. 1.264 vs TV 1.282, 1.190 vs 1.201, 1.133 vs 1.155 across ~520-600 trades each.

Happy to share the three Pine sources, the OHLCV CSV and the TradingView exports privately if useful. Thanks for the engine - the parity is otherwise remarkable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions