Event and state functions in formulas

Use functions that react to changes, crossings, and state over time.

Event/state functions are useful when a formula must remember or react to something rather than simply recalculate a static arithmetic expression.

Examples

  • CROSSES_UP: detects an upward crossing between values
  • Changes / ChangesTo: reacts to a series change or a change to a target value
  • Accumulate: maintains a running value with optional reset behavior
  • SnapshotNum: captures a number when a trigger fires
  • HighestSince / LowestSince: tracks extremes since a reset
  • SumSince: maintains a running total since a reset
  • StartTime / RestartTime: initialization and restart events

Why this matters

A one-time stop adjustment, breakout event, or value captured at entry usually requires event/state thinking rather than a formula that continuously recomputes the same test.

See also: Formula Editor & XapiScript complete reference.

Was this article helpful?

Get Started Now!

Try out our technology for free or open an account and start trading.

There is a substantial risk of loss in trading futures and options.