|
PineForge v0.12.3-30-g11e61d4
Deterministic PineScript v6 backtest runtime — C ABI 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). | |
| int32_t | open_at_end |
| 1 when this row is the RANGE-END close of a position that was still open after the final bar; 0 for an exit the script or a bracket produced. | |
Closed-trade record returned in pf_report_t::trades.
Layout-compatible with internal pineforge::TradeC.
Definition at line 139 of file pineforge.h.
| int64_t pf_trade_t::entry_time |
Entry fill time (Unix ms).
Definition at line 140 of file pineforge.h.
| int64_t pf_trade_t::exit_time |
Exit fill time (Unix ms).
Definition at line 141 of file pineforge.h.
| double pf_trade_t::entry_price |
| double pf_trade_t::exit_price |
| double pf_trade_t::pnl |
Net realized PnL in account currency (commission-inclusive).
Definition at line 144 of file pineforge.h.
| 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 145 of file pineforge.h.
| int pf_trade_t::is_long |
1 if long, 0 if short.
Definition at line 153 of file pineforge.h.
| double pf_trade_t::max_runup |
Peak favorable price travel during the trade ($/unit qty).
Definition at line 154 of file pineforge.h.
| double pf_trade_t::max_drawdown |
Peak adverse price travel during the trade ($/unit qty).
Definition at line 155 of file pineforge.h.
| double pf_trade_t::qty |
Filled quantity.
Definition at line 156 of file pineforge.h.
| double pf_trade_t::commission |
Entry+exit commission actually deducted from pnl (account currency).
pnl is already net of this.
Definition at line 157 of file pineforge.h.
| int32_t pf_trade_t::entry_bar_index |
Script-bar index of the entry fill (0-based).
Definition at line 159 of file pineforge.h.
| int32_t pf_trade_t::exit_bar_index |
Script-bar index of the exit fill (0-based).
Definition at line 160 of file pineforge.h.
| int32_t pf_trade_t::open_at_end |
1 when this row is the RANGE-END close of a position that was still open after the final bar; 0 for an exit the script or a bracket produced.
TradingView's deep-backtest report does not leave the last position open: it reports it as a closed trade whose exit leg is the range's last bar at that bar's CLOSE, with an empty exit Signal, and counts it in closedTrades (orb-lite on NYSE:F 1D: Entry short 2026-03-16 @ 11.82, Exit 2026-04-30 @ 12.08 = the last close, closedTrades:1). The engine emulates that row (operator decision 2026-09-02): exit_time is the last script bar's label, exit_price its mintick-rounded close with no slippage, commission per the strategy's rules, pnl/pnl_pct/excursions as for any close. Appended in ABI v3.
Definition at line 161 of file pineforge.h.