PineForge v0.1.2-11-ga87241d
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
Strategy lifecycle

Create, run, and destroy a compiled strategy instance. More...

Functions

pf_strategy_t strategy_create (const char *params_json)
 Allocate a new strategy instance.
 
void strategy_free (pf_strategy_t s)
 Release a strategy handle previously returned by strategy_create.
 
void run_backtest (pf_strategy_t s, pf_bar_t *bars, int n, pf_report_t *out)
 Run a backtest with auto-detected timeframe and no bar magnifier.
 
void run_backtest_full (pf_strategy_t s, pf_bar_t *bars, int n, const char *input_tf, const char *script_tf, int bar_magnifier, int magnifier_samples, pf_magnifier_distribution_t magnifier_dist, pf_report_t *out)
 Run a backtest with explicit timeframe and magnifier configuration.
 
void report_free (pf_report_t *report)
 Free heap arrays attached to a filled report.
 

Detailed Description

Create, run, and destroy a compiled strategy instance.

Function Documentation

◆ strategy_create()

pf_strategy_t strategy_create ( const char * params_json)

Allocate a new strategy instance.

Parameters
params_jsonCurrently ignored; pass NULL.
Returns
Strategy handle, or NULL on allocation failure.

Caller owns the returned handle and must release it via strategy_free.

References PF_API.

◆ strategy_free()

void strategy_free ( pf_strategy_t s)

Release a strategy handle previously returned by strategy_create.

Safe to call with NULL. Invalidates any pf_report_t::trace_names pointers obtained from this strategy.

References PF_API.

◆ run_backtest()

void run_backtest ( pf_strategy_t s,
pf_bar_t * bars,
int n,
pf_report_t * out )

Run a backtest with auto-detected timeframe and no bar magnifier.

Parameters
sStrategy handle from strategy_create.
barsNon-NULL pointer to OHLCV bars (length n).
nBar count (>= 0).
outNon-NULL output report. Fields are populated with heap allocations the caller must release via report_free.

References PF_API.

◆ run_backtest_full()

void run_backtest_full ( pf_strategy_t s,
pf_bar_t * bars,
int n,
const char * input_tf,
const char * script_tf,
int bar_magnifier,
int magnifier_samples,
pf_magnifier_distribution_t magnifier_dist,
pf_report_t * out )

Run a backtest with explicit timeframe and magnifier configuration.

Parameters
sStrategy handle.
barsBar feed.
nBar count.
input_tfInput timeframe ("1", "5", "15", "60", "1D", ...). Empty string → auto-detect from bar timestamps.
script_tfScript timeframe. Empty string → defaults to input_tf.
bar_magnifierBoolean (0 / non-zero) — enable bar magnifier.
magnifier_samplesSub-bar samples per parent bar (typical: 4).
magnifier_distSampling distribution (see pf_magnifier_distribution_t).
outOutput report. Free with report_free.

References PF_API.

◆ report_free()

void report_free ( pf_report_t * report)

Free heap arrays attached to a filled report.

Idempotent. Safe to call with NULL or an already-freed report. The pf_report_t struct itself is caller-owned.

References PF_API.