|
PineForge v0.1.2-7-ga095e36
Deterministic PineScript v6 backtest runtime — C ABI reference
|
Deterministic PineScript v6 backtest runtime, validated trade-for-trade against TradingView.
PineForge is the C++ runtime that PineForge-compiled strategies link against. It implements PineScript v6 strategy semantics — order matching, fills, the bar magnifier, technical indicators, time / session math — as a static C++ library with a stable C ABI.
This site is the public consumer reference: the C ABI declared in <pineforge/pineforge.h>, the lifecycle of a strategy handle, the shape of the report returned by a backtest, and how to integrate the library from CMake or via FFI.
<pineforge/engine.hpp>, <pineforge/ta.hpp>, ...) are used by the closed PineForge transpiler and are deliberately omitted from this reference. They are not part of the stability guarantee and not recommended for direct external consumption.pineforge.h — or jump to the Pure C or Rust worked examples.Five end-to-end, runnable examples that go beyond the MACD tutorial:
| Example | Use case |
|---|---|
| Tutorial: MACD on BTCUSDT | The 60-second backtest. Start here. |
| Pure C harness | One file, no Python, dlopen + run. |
| Parameter sweep in Python | Re-run one .so over a 2-D grid; sticky configuration; walk-forward variant. |
| Multi-strategy harness | Load N .so files; rank by net PnL; thread-pool execution. |
| Magnifier on vs off | A/B comparison with all six distribution modes. |
| Calling from Rust | Idiomatic libloading wrapper with safe Rust types. |
The entire public surface fits in one header and 10 functions:
| Group | Symbols | Reference |
|---|---|---|
| Lifecycle | strategy_create, strategy_free, run_backtest, run_backtest_full, report_free | Strategy lifecycle |
| Configuration | strategy_set_input, strategy_set_override, strategy_set_magnifier_volume_weighted, strategy_set_trace_enabled, strategy_set_trade_start_time | Per-strategy configuration |
| Version | pf_version_get, pf_version_string | Version query |
| Types | pf_bar_t, pf_trade_t, pf_report_t, pf_security_diag_t, pf_trace_entry_t, pf_version_t, pf_magnifier_distribution_t | Types |
Every PineForge-generated strategy .so exports exactly these symbols and zero internal C++ symbols — see ABI stability for the full guarantee.
Build: cc demo.c -lpineforge -lstdc++ -lm. That's it.
libpineforge.a). The PineScript-to-C++ transpiler is a separate, closed-source product; this runtime is what every compiled strategy .so links against.