TradingView event research

Post-earnings announcement drift: establish when the signal existed

Post earnings announcement drift (PEAD) is the tendency studied in financial research for returns after an earnings release to continue in the direction of the earnings surprise. Testing it requires an expectation recorded before the announcement, the first reported result on the same accounting basis, and an entry that occurs after the information becomes available. An earnings beat alone is neither a trade rule nor evidence of future profit. This guide defines a long-only research example and a single-event Pine timing audit.

See the decision guide

Define surprise before selecting winners

The example uses analyst-consensus surprise: S = 100 × (A - E) / |E|, where A is the first reported EPS and E is a frozen pre-announcement consensus for the same fiscal period, currency, share basis, and accounting definition. This percentage is not standardized unexpected earnings (SUE). A historical seasonal earnings model or a volatility-scaled SUE measure would define a different experiment.

  • Predefine a denominator floor. Here |E| must be at least 0.05 in the selected EPS currency units. This arbitrary research setting excludes unstable near-zero ratios and must be reported with the sample count.
  • Do not compare adjusted consensus EPS with reported GAAP EPS, or basic EPS with diluted EPS, without an explicit reconciliation. A large computed difference can be a definition mismatch.
  • Record how the consensus was formed and its cutoff time. An estimate published after the earnings release is unavailable for the original decision even if it refers to the correct quarter.
Illustrative inputCalculationDecision at a +5% threshold
Actual 1.20; estimate 1.00100 × (1.20 - 1.00) / 1.00 = +20%Qualifies for the long-only example.
Actual -0.10; estimate -0.20100 × (-0.10 + 0.20) / 0.20 = +50%A smaller loss is a positive surprise; still verify matching definitions.
Actual 0.02; estimate 0.00Percentage denominator is zero.Exclude under this rule; do not substitute zero surprise.
Actual 1.20; estimate missingNo valid surprise can be computed.Record missing consensus; do not carry forward a prior quarter.

An event record needs more than an earnings date

Maintain one immutable original record per symbol and fiscal-period announcement. Set availableAt to the later of the public release time and the time the required result reached your research or execution system. Preserve timezone offsets and source documents. A calendar date or a later filing timestamp alone cannot establish the first moment the news was tradable.

  • If the release time is unknown, exclude it from an exact-time test and retain the reason. A separately reported date-only sensitivity test may delay entry by a full session, but that does not recover the missing timestamp.
  • For this baseline, a later accounting correction does not alter the frozen entry signal. Stop using a corrupted record for new decisions and document any separate correction-based exit policy before testing it.
RecordWhat to preserveWhy it changes the test
Event identityExchange symbol, issuer identifier, fiscal-period end, original release URL.Separates another quarter, a duplicate feed message, and an amended release.
Publication and receiptRelease timestamp, timezone, feed receipt timestamp, any known latency.Prevents assigning a 16:15 release to a 16:00 close.
Expectation snapshotConsensus value, basis, contributor policy, snapshot timestamp before release.Prevents using a revised or post-release expectation.
First actual and correctionsOriginal EPS and basis; later corrections as separate timestamped versions.A later revision must not retroactively change an earlier trade.
Execution contextRegular or extended session, holiday calendar, chart settings, entry and exit timestamps.A session rule determines which later price can be a fill.

Use an explicit after-hours and holding-window rule

The daily baseline waits for the first completed regular-session 1D bar whose closing timestamp is strictly later than availableAt. If the frozen surprise is at least +5%, it submits one market buy for one share, filled at the next available bar open under the default strategy model. It closes after 20 completed daily bars in the position, with the exit order filled at the following open. These settings are illustrative and are not optimized.

  • A different strategy could enter Tuesday open after a Monday after-hours release. The daily bar-close script below cannot submit that order after Monday 16:15 when its last calculation was Monday 16:00. Testing the earlier entry needs an appropriate intraday or external event-driven execution model.
  • Reject overlapping same-symbol events in a multi-event extension while a position is open; log the exclusion. Stop accepting new entries at a predefined study cutoff and report positions lacking a later exit bar as open or censored.
  • This baseline has no protective stop or short leg. Overnight gaps can cause substantial losses. One share isolates timing and is not a position-sizing recommendation.
Illustrative releaseDaily decisionEarliest modeled entry
Monday 08:00, before a 09:30 openMonday regular-session close.Tuesday open. The baseline intentionally waits through Monday.
Monday 12:00, during the sessionMonday regular-session close.Tuesday open; no fill at the earlier Monday open.
Monday 16:15, after a 16:00 closeTuesday regular-session close.Wednesday open, assuming both sessions trade normally.
Friday after close before a Monday holidayTuesday close, if Tuesday is the next session.Wednesday open; count trading bars, not calendar days.

Pine Script for one frozen earnings event

Use standard 1D candles with regular-session data and keep the calculation settings below. Replace the synthetic timestamp and EPS inputs with one documented event, then enable the snapshot checkbox. The script has no automatic earnings feed: it audits order timing from values you supply. It does not verify the source, detect revisions, reconstruct historical consensus, or establish a PEAD effect across companies.

  • Load history containing a completed bar before availableAt and enough later bars for entry and exit. The crossing condition deliberately avoids triggering when the chart begins after the event. No signal can therefore also mean insufficient history.
  • With holdBars = 1, entry at Tuesday open leads to an exit order at Tuesday close and a fill at Wednesday open. With 20, count the entry day as held bar 1 and exit after held bar 20 closes.
  • The interval guard cannot enforce standard candles, regular-session settings, or your snapshot accuracy. Select and record those settings manually. The 0.10% fee per fill and two ticks of adverse slippage are cost assumptions, not broker estimates.
  • TradingView provides request.earnings fields for actual, estimated, and standardized EPS. Event gaps and lookahead settings control series placement, but do not establish that a present-day dataset preserves every original estimate, first publication timestamp, or later correction. Verify the feed before replacing the frozen inputs.
One synthetic event, disabled until the snapshot is confirmed. Syntax validation checks compilation, not the truth of the manually entered timestamp or EPS values.pine
//@version=6
strategy("PEAD single-event timing audit", overlay = true,
     initial_capital = 100000, pyramiding = 0,
     default_qty_type = strategy.fixed, default_qty_value = 1,
     margin_long = 100, commission_type = strategy.commission.percent,
     commission_value = 0.10, slippage = 2,
     calc_on_every_tick = false, calc_on_order_fills = false,
     process_orders_on_close = false)

bool verified = input.bool(false, "I verified this event snapshot")
int availableAt = input.time(timestamp("06 Jan 2025 16:15 -0500"), "Information available at")
float actual = input.float(1.20, "First reported EPS")
float expected = input.float(1.00, "Pre-release consensus EPS")
float floorEPS = input.float(0.05, "Minimum absolute estimate", minval = 0.0001)
float threshold = input.float(5.0, "Minimum positive surprise (%)", minval = 0.0)
int holdBars = input.int(20, "Completed daily bars held", minval = 1)

if not timeframe.isdaily or timeframe.multiplier != 1
    runtime.error("Use standard 1D candles with regular-session data.")

bool validEPS = verified and math.abs(expected) >= floorEPS
float surprise = validEPS ? 100.0 * (actual - expected) / math.abs(expected) : na
bool eventBar = not na(time_close[1]) and time_close[1] <= availableAt and time_close > availableAt
bool entrySignal = barstate.isconfirmed and eventBar and validEPS and surprise >= threshold

if entrySignal and strategy.position_size == 0
    strategy.entry("PEAD", strategy.long)

if barstate.isconfirmed and strategy.position_size > 0
    int entryBar = strategy.opentrades.entry_bar_index(0)
    if bar_index - entryBar + 1 >= holdBars
        strategy.close("PEAD")

plotshape(entrySignal, title = "Decision after availability", style = shape.triangleup,
     location = location.belowbar, color = color.blue, size = size.small)
plot(eventBar ? surprise : na, "Frozen surprise (%)", display = display.data_window)

Separate the announcement gap from the later return

Consider invented prices and one share. The pre-release close is $50, the executable entry is $51, and the exit is $53. The earlier $1 rise is excluded. The trade return is 100 × (53 / 51 - 1) = 3.9216%, whereas using $50 as the entry would report 6% and include an unavailable gain. These numbers are arithmetic examples, not observed PEAD performance.

  • At 0.10% commission per fill, fees are $0.051 + $0.053 = $0.104. Net P&L before slippage is $2 - $0.104 = $1.896, or 3.7176% of the $51 entry notional.
  • If the tick is $0.01 and two adverse ticks apply at both ends, execution becomes $51.02 and $52.98. Fees remain $0.104; net P&L is $1.856, or 3.6378% of $51.02. Real spreads, impact, taxes, and financing may differ.
  • For an event study, define a benchmark separately. Daily abnormal return can be AR(t) = stock return(t) - benchmark return(t); CAR is the sum of those daily differences over the specified event window. CAR is not automatically a compounded or executable portfolio return.
  • Report the initial announcement reaction and later-window result separately. Positive raw returns during a broad market rise do not by themselves demonstrate earnings-related abnormal performance.

Missing events and revisions belong in the result

Freeze the historical universe and exclusion rules before inspecting outcomes. A sample consisting only of currently listed companies with complete consensus data can omit delistings, smaller issuers, and difficult events. More chart candles do not increase the number of earnings announcements observed.

  • For a hypothetical 100 announcements, 12 missing estimates, 3 basis mismatches, and 5 unknown times leave 80 eligible records if those exclusion groups do not overlap. If 18 meet the threshold, report 100 total, 20 excluded, 62 eligible non-signals, and 18 signals. Closed trades may be fewer than 18.
  • Reserve later event dates before choosing thresholds or holding periods. Compare costs and nearby settings on development data, then evaluate the frozen rule on untouched events. A best historical setting can result from repeated searches.
  • A long-only chart test does not reproduce an academic long-short, cross-sectional portfolio. Portfolio weights, simultaneous holdings, borrow costs, delisted assets, and correlated events require separate research infrastructure.
ProblemBaseline treatmentRequired disclosure
Missing or mismatched estimateExclude before computing the signal.Count and reason, including EPS basis mismatches and denominator-floor exclusions.
Unknown exact release timeExclude from the exact-time sample.Count separately from nonqualifying surprises.
Later revision or duplicate feed messageRetain the original record; append a version or mark a duplicate.Do not create another original event or rewrite its historical surprise.
Suspension, delisting, or missing exitDo not assume a zero return or a fill during a halt.Use a documented resolution and valuation policy; disclose unresolved and censored observations.
Several firms release togetherKeep all eligible events under the original universe rule.Account for shared market exposure and clustered event dates when assessing uncertainty.

Turn the event specification into an auditable strategy

Give Pine Script AI Coding Agent the frozen input format, availability rule, bar-count convention, overlap policy, and cost assumptions when drafting a larger script. Review every generated decision timestamp against its event record. Strategy Optimizer can compare exposed strategy-input combinations after that audit; changing holding periods cannot repair future information in the input data.

  • Keep event timestamp and EPS snapshot fields fixed during optimization. Search only a predeclared small set of rule parameters across a sufficient event sample, not the inputs that describe what happened.
  • The one-event script is a timing check, not a sensible sample for choosing profitable parameters. Keep the event ledger, excluded records, code version, and held-out evaluation outside the optimization result table.
Where Pineify fits

Pine Script AI Coding Agent

Draft Pine rules from an explicit earnings-event specification, then inspect the source and compare signal timestamps with your frozen event records.

Also useful: Strategy Optimizer. Compare strategy-input combinations after validating data timing and costs. Parameter search does not supply historical consensus snapshots or prove an earnings effect.

Draft an earnings-event strategy

Frequently asked questions

Educational research, not investment advice or an individual-stock recommendation. All numerical examples and script defaults are synthetic. No profitable strategy or historical PEAD result is claimed. Trading involves loss risk; compilation and backtests cannot guarantee future returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.