Define the observation before calculating its duration
Use actual simulated fill timestamps for a TradingView backtest and broker fill timestamps for live trading. A signal timestamp or order submission timestamp can precede execution. Choose one observation unit: a matched entry/exit lot, an exit slice, or a complete position episode from flat to flat. Mixing those units changes the average even when the executions are identical.
- For milliseconds, d = (exit timestamp - entry timestamp) / 86,400,000 gives elapsed 24-hour days. Divide by 3,600,000 for hours. This counts nights and weekends.
- Specify the cohort: entries during a window, exits during a window, or all positions touching it. These select different trades. If the entry precedes your export, recover it or mark the duration unknown; the export start is not the entry.
- Keep long and short observations on the same clock. Duration is nonnegative for either direction; a short position does not have a negative holding period.
| Input | Required definition | Reason |
|---|---|---|
| Trade identifier | Unique matched lot or position episode | Two CSV rows can describe one trade; do not count both as two durations. |
| Entry and exit | Fill instants with time zone or UTC offset | Subtract instants, not unrelated local clock labels. |
| Status and cutoff | Closed, or open at a fixed observation instant | An open age is only a lower bound on eventual duration. |
| Weight | Positive entry capital in one reporting currency | Quantity, notional, margin and P&L weights answer different questions. |