|
PineForge v0.10.12
Deterministic PineScript v6 backtest runtime — C ABI reference
|
Override input.
More...
Functions | |
| void | strategy_set_input (pf_strategy_t s, const char *key, const char *value) |
Override a Pine input. | |
| void | strategy_set_override (pf_strategy_t s, const char *key, const char *value) |
Override a strategy(...) declaration parameter. | |
| void | strategy_set_magnifier_volume_weighted (pf_strategy_t s, int on) |
| Toggle volume-weighted bar-magnifier sampling. | |
| void | strategy_set_trace_enabled (pf_strategy_t s, int on) |
| Toggle per-bar trace recording. | |
| void | strategy_set_trade_start_time (pf_strategy_t s, int64_t timestamp_ms) |
| Set the earliest Unix-ms timestamp at which strategy order commands may fire. | |
| void | strategy_set_chart_timezone (pf_strategy_t s, const char *tz) |
| Set the strategy's chart timezone (IANA / POSIX TZ string). | |
| void | strategy_set_syminfo_timezone (pf_strategy_t s, const char *tz) |
| Plumb the symbol's exchange timezone (IANA string) into syminfo. | |
| void | strategy_set_syminfo_session (pf_strategy_t s, const char *session) |
| Set the symbol's session string (e.g. | |
| void | strategy_set_syminfo_mintick (pf_strategy_t s, double mintick) |
Set the instrument tick size (syminfo.mintick, default 0.01). | |
| void | strategy_set_syminfo_pointvalue (pf_strategy_t s, double pointvalue) |
Set the instrument point value (syminfo.pointvalue, default 1.0) — the $-per-point-per-contract multiplier applied to every money path: realized PnL and MFE/MAE, open profit / mark-to-market equity (and the drawdown / runup extremes), percent-of-equity and cash position sizing, percent commission notionals, and the margin admission check. | |
| void | strategy_set_syminfo_metadata (pf_strategy_t s, const char *key, double value) |
| Inject a fundamental/exchange metadata value by Pine member name (e.g. | |
| const char * | strategy_get_last_error (pf_strategy_t s) |
| Returns the error message captured by the most recent run_backtest / run_backtest_full call on this strategy. | |
Override input.
*() values, strategy(...) params, and runtime knobs.
| void strategy_set_input | ( | pf_strategy_t | s, |
| const char * | key, | ||
| const char * | value ) |
Override a Pine input.
*() value before the next run.
| s | Strategy handle. |
| key | The input's title (or fallback identifier). |
| value | Serialized value — numbers as decimal strings, booleans as "true" / "false". |
Calls after run_backtest are accepted but only take effect on subsequent runs.
References PF_API.
| void strategy_set_override | ( | pf_strategy_t | s, |
| const char * | key, | ||
| const char * | value ) |
Override a strategy(...) declaration parameter.
Recognised key values: initial_capital, commission_value, default_qty_value, pyramiding, slippage, process_orders_on_close, close_entries_rule, default_qty_type, commission_type.
References PF_API.
| void strategy_set_magnifier_volume_weighted | ( | pf_strategy_t | s, |
| int | on ) |
Toggle volume-weighted bar-magnifier sampling.
Has no effect unless the bar magnifier is enabled in run_backtest_full.
References PF_API.
| void strategy_set_trace_enabled | ( | pf_strategy_t | s, |
| int | on ) |
Toggle per-bar trace recording.
Default off (zero-cost when off).
Enables capture for // @pf-trace name=expr pragmas already compiled into the strategy .so. Trace records appear in pf_report_t::trace.
References PF_API.
| void strategy_set_trade_start_time | ( | pf_strategy_t | s, |
| int64_t | timestamp_ms ) |
Set the earliest Unix-ms timestamp at which strategy order commands may fire.
Earlier bars still execute user code and warm TA/series state, but strategy.entry/order/exit/close commands are ignored.
References PF_API.
| void strategy_set_chart_timezone | ( | pf_strategy_t | s, |
| const char * | tz ) |
Set the strategy's chart timezone (IANA / POSIX TZ string).
Pine builtins hour, minute, second, dayofmonth, dayofweek, month, year and weekofyear return the wall-clock for the chart's timezone — TV exports trade rows in chart TZ too. Engine bars are stored as Unix-ms (UTC), so without this override these builtins return UTC and silently diverge from TV by N hours when the chart is on a non-UTC zone (Asia/Taipei = UTC+8 is the validator default).
Pass NULL, "", "UTC" or "Etc/UTC" for the legacy UTC behaviour (cheap, mutex-free). Any other value names a TZ resolved by the system tzdata; the per-bar decomposition then runs under a process-global mutex so multi-threaded harnesses don't corrupt each other's wall time.
Should be called before run_backtest / run_backtest_full. Persists across runs on the same strategy handle until overridden.
References PF_API.
| void strategy_set_syminfo_timezone | ( | pf_strategy_t | s, |
| const char * | tz ) |
Plumb the symbol's exchange timezone (IANA string) into syminfo.
Feeds session.ismarket / time(session) predicates. Defaults to "UTC" (crypto). Distinct from strategy_set_chart_timezone — the chart TZ drives wall-clock builtins and intraday-cap day rollover; this drives session membership. NULL is ignored. Call before run_backtest*.
References PF_API.
| void strategy_set_syminfo_session | ( | pf_strategy_t | s, |
| const char * | session ) |
Set the symbol's session string (e.g.
"0930-1600:23456", default "24x7"). Feeds session.ismarket / time(session). NULL ignored. Call before run_backtest*.
References PF_API.
| void strategy_set_syminfo_mintick | ( | pf_strategy_t | s, |
| double | mintick ) |
Set the instrument tick size (syminfo.mintick, default 0.01).
Drives the directional stop-entry snap and slippage = N*mintick economics. Set per-instrument (e.g. 0.25 for ES, 0.00001 for FX). Non-positive ignored. Call before run_backtest*.
References PF_API.
| void strategy_set_syminfo_pointvalue | ( | pf_strategy_t | s, |
| double | pointvalue ) |
Set the instrument point value (syminfo.pointvalue, default 1.0) — the $-per-point-per-contract multiplier applied to every money path: realized PnL and MFE/MAE, open profit / mark-to-market equity (and the drawdown / runup extremes), percent-of-equity and cash position sizing, percent commission notionals, and the margin admission check.
Set per-instrument (e.g. 50 for ES). Non-positive ignored. Call before run_backtest*.
References PF_API.
| void strategy_set_syminfo_metadata | ( | pf_strategy_t | s, |
| const char * | key, | ||
| double | value ) |
Inject a fundamental/exchange metadata value by Pine member name (e.g.
"shares_outstanding_total", "target_price_average"). These have no OHLCV source; reads of un-injected members return na. Call before run_backtest*.
References PF_API.
| const char * strategy_get_last_error | ( | pf_strategy_t | s | ) |
Returns the error message captured by the most recent run_backtest / run_backtest_full call on this strategy.
Returns an empty string when the run completed normally, or NULL only when s itself is NULL. The pointer is owned by the engine and remains valid until the next run_backtest* call (which clears the captured error before it begins).
The runtime catches every std::exception derivative inside the engine's run loop so the C ABI never unwinds a C++ exception across the extern "C" boundary. Consumers must check this after every run to surface engine-rejected configurations such as a script timeframe finer than the input timeframe, a request.security timeframe below the chart timeframe without a supported lower-TF emulation, or a missing input timeframe when securities are registered.
References PF_API.