Practical tutorials

Investigate an unexpected trade

Trace one outcome backward through requests, decisions, state, and data.

Prerequisites

Choose one completed historical run or a captured running-session event. Retain its saved revision, server/run identity, instrument, and execution environment. Use existing evidence before changing source.

Anchor the investigation

Select the unexpected trade and record its side, quantity, price, time, and order identity when available. Confirm that you selected the intended app or follower and the correct run.

Do not assume a chart marker's display time is the signal-production time or request time. For the Pine tutorial, signal time and consuming-frame time intentionally differ.

Work backward

  1. Find the request associated with the outcome. Check source, metadata, and requested quantity.
  2. Find the originating decision. Compare its recorded signal to the source revision that ran.
  3. Inspect pending orders and position state used by the decision. A previous accepted request may not yet have filled.
  4. Check the input bar, timestamp, warmup, and relevant indicator values.
  5. Inspect automation mode, L3 checks, and the selected simulator or broker behavior.

Expected outcome: an explanation of the first stage that differed from your intended behavior, not merely a changed strategy that hides the symptom.

Reproduce the first divergence

For a historical case, rerun the smallest window that still includes required initialization history. Keep execution settings fixed. Add a compact diagnostic record only for the evidence you are missing, then save a new revision.

For a broker case, distinguish request acceptance, fills, and account updates. Historical replay may reproduce the decision without reproducing the broker outcome.

Common findings

ObservationLikely next check
Two entry attempts for one eventMultiple execution owners, repeated callbacks, or process-state reset
Exit signal with no close requestPending orders, wrong position side, or consumed event policy
Approved request without a tradeEligibility, delay, price conditions, or broker rejection
Trade appears after stoppingOutstanding broker order or delayed account update
Different result after restartNew runtime state, initialization, account state, or a different saved source

Do not treat stored server results as a live account reconciliation. Verify remaining orders and positions through the appropriate account path.

Next: backtest, inspect, and launch.

On this page