PineForge v0.10.12
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
pf_trade_t Struct Reference

Closed-trade record returned in pf_report_t::trades. More...

#include <pineforge.h>

Data Fields

int64_t entry_time
 Entry fill time (Unix ms).
 
int64_t exit_time
 Exit fill time (Unix ms).
 
double entry_price
 Entry fill price (incl.
 
double exit_price
 Exit fill price (incl.
 
double pnl
 Net realized PnL in account currency (commission-inclusive).
 
double pnl_pct
 Net return-on-cost in percent: pnl (NET of commission) / entry cost (entry_price * qty * pointvalue) * 100.
 
int is_long
 1 if long, 0 if short.
 
double max_runup
 Peak favorable price travel during the trade ($/unit qty).
 
double max_drawdown
 Peak adverse price travel during the trade ($/unit qty).
 
double qty
 Filled quantity.
 
double commission
 Entry+exit commission actually deducted from pnl (account currency).
 
int32_t entry_bar_index
 Script-bar index of the entry fill (0-based).
 
int32_t exit_bar_index
 Script-bar index of the exit fill (0-based).
 

Detailed Description

Closed-trade record returned in pf_report_t::trades.

Layout-compatible with internal pineforge::TradeC.

Definition at line 119 of file pineforge.h.

Field Documentation

◆ entry_time

int64_t pf_trade_t::entry_time

Entry fill time (Unix ms).

Definition at line 120 of file pineforge.h.

◆ exit_time

int64_t pf_trade_t::exit_time

Exit fill time (Unix ms).

Definition at line 121 of file pineforge.h.

◆ entry_price

double pf_trade_t::entry_price

Entry fill price (incl.

slippage).

Definition at line 122 of file pineforge.h.

◆ exit_price

double pf_trade_t::exit_price

Exit fill price (incl.

slippage).

Definition at line 123 of file pineforge.h.

◆ pnl

double pf_trade_t::pnl

Net realized PnL in account currency (commission-inclusive).

Definition at line 124 of file pineforge.h.

◆ pnl_pct

double pf_trade_t::pnl_pct

Net return-on-cost in percent: pnl (NET of commission) / entry cost (entry_price * qty * pointvalue) * 100.

This is TradingView's "Net P&L %" convention, arbitrated 2026-06-12 against a real TV export (trade #258 short: 102.44 USD on a 2276.66 entry => 4.50%). Degenerates to the old gross (exit/entry-1)*100 form for longs with zero commission; the previous short form (entry/exit-1)*100 was wrong on large moves. Sign always matches pnl.

Definition at line 125 of file pineforge.h.

◆ is_long

int pf_trade_t::is_long

1 if long, 0 if short.

Definition at line 133 of file pineforge.h.

◆ max_runup

double pf_trade_t::max_runup

Peak favorable price travel during the trade ($/unit qty).

Definition at line 134 of file pineforge.h.

◆ max_drawdown

double pf_trade_t::max_drawdown

Peak adverse price travel during the trade ($/unit qty).

Definition at line 135 of file pineforge.h.

◆ qty

double pf_trade_t::qty

Filled quantity.

Definition at line 136 of file pineforge.h.

◆ commission

double pf_trade_t::commission

Entry+exit commission actually deducted from pnl (account currency).

pnl is already net of this.

Definition at line 137 of file pineforge.h.

◆ entry_bar_index

int32_t pf_trade_t::entry_bar_index

Script-bar index of the entry fill (0-based).

Definition at line 139 of file pineforge.h.

◆ exit_bar_index

int32_t pf_trade_t::exit_bar_index

Script-bar index of the exit fill (0-based).

Definition at line 140 of file pineforge.h.


The documentation for this struct was generated from the following file: