Back to builder reference

Value ref

event_distance

Distance from the current bar to an event type's next or previous occurrence.

direction="previous" counts back to the latest occurrence at or before the bar: 0 on the assignment bar only for unit="bars". Minutes uses elapsed wall-clock time from the occurrence timestamp to the bar timestamp. direction="next" counts forward to the earliest occurrence strictly after the bar, so it is never 0 in minutes. unit is wall-clock minutes or bars.

When no such occurrence is known the value is infinity (present, not absent), so distance <= N is false and not (distance <= N) is true: that is how a "stay away from events" gate is written.

A next distance needs the event's date to be known in advance. Among system events only those with a forward release calendar (macro.cpi, macro.nonfarm_payrolls, macro.unemployment) qualify; any other system event is refused with direction="next", because the platform cannot anticipate it. Custom events are unrestricted. Use direction="previous" to react after a system event.

Example, bars since the latest occurrence: {"kind": "event_distance", "event_type_id": "my-signal", "direction": "previous", "unit": "bars"}

Compared <= N it is true on the occurrence bar and the N bars after it, with <ref> the ref above: {"kind": "compare", "left": <ref>, "op": "<=", "right": N} That compare is also the proximity guard for an event_field read: put both under all_of so the payload comparison holds only near an occurrence instead of carrying forward until the next one.

Backing types

EventDistanceValueRef

Required fields

directionreqenum: next, previous'previous' = distance back to the latest occurrence at or before this bar. 'next' = distance forward to the earliest occurrence after this bar; needs a custom event or a system event with a forward release calendar.
event_type_idreqstringEvent type ID from list_event_types().

Optional fields

kindstring-
resolutionnullUnsupported on this value ref; only null is accepted.
symbolnullUnsupported on this value ref; only null is accepted.
unitanyOf (2 variants)Measure the distance in wall-clock minutes or in bars; minutes when omitted.

Backing types

The IR ValueRef classes this builder field resolves to.

EventDistanceValueRef
Quawd

A subscription SaaS platform for designing, backtesting, and paper-trading algorithmic trading strategies on equities and crypto — described in plain English to an AI agent, no code required.

© 2026 Quawd. All rights reserved.

Quawd is a software tool, not a broker-dealer or investment adviser, and does not provide investment advice. Trading involves substantial risk of loss. Backtested and hypothetical results have inherent limitations and are not indicative of future performance.