Value ref
event_distanceDistance 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 bar the occurrence is assigned to. 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, within 5 bars after an event: {"kind": "event_distance", "event_type_id": "my-signal", "direction": "previous", "unit": "bars"}
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-resolutionanyOf (2 variants)Optional higher-timeframe override for this value ref. Set it inside left/right refs such as {'kind': 'indicator', ..., 'resolution': '4h'} or {'kind': 'price', 'field': 'close', 'resolution': '4h'}. Do not put timeframe/source_timeframe on the parent condition. None = strategy timeframe.symbolanyOf (2 variants)Optional reference symbol this value ref reads from (e.g. 'SPY'). None = the traded/primary symbol. Mutually exclusive with resolution.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.