Skip to main content
Some values an indicator computes are meant for alerts, not for the chart. Indie has two kinds of outputs for them. Neither is drawn, and both are listed as alert sources:
  • An event output (@plot.event) reports that something happened on a bar: a cross, a breakout, a volume spike. Users create an alert on the event by name, for example MACD cross: Bullish cross, instead of building a value condition on a plotted line.
  • A data output (@plot.data) carries a number, such as a stop level or the ATR, that users can set value conditions on or put into the alert message, without adding a line to the chart.
Like any other plot, each of them takes one slot in the tuple that Main returns.

Event outputs

Declare an event output with the @plot.event decorator.

Syntax

  • id: a unique identifier of the output, as for other plots.
  • title: the name users see in the alert dialog. If omitted, the id is used.
  • options: a list of the events this output can report, such as ['Bullish cross', 'Bearish cross']. Leave it out for a single event.
What Main returns for the output depends on options:

An output with several options

The indicator below plots MACD and its signal line and reports crosses of the two as one event output with two options.
event is None on some paths and a string on others, so it needs the Optional[str] annotation. A conditional expression needs none, so the same output can be written in one line:
The chart shows only the two lines. In the alert dialog, the MACD cross output offers Bullish cross, Bearish cross and Any.

A single event

Without options, the output is one event and Main returns a bool:
An indicator can declare as many event outputs as it needs, next to its regular plots. Group related events into one output with options (for example, the bullish and bearish variants of the same signal), and use separate outputs for unrelated events.

Creating an alert on an event

  1. Add the indicator to the chart and open the alert dialog (see Alerts overview).
  2. Choose the indicator as the source, then pick the event output by its title, for example MACD cross.
  3. For an output with options, pick one option, for example Bullish cross, or Any to be notified about every option. A single event has nothing more to choose.
For event outputs the dialog hides the criteria and the target value. Frequency defaults to Once Per Bar Close, so the alert fires once, on the bar where the event happened. You can change it under the additional settings. The default alert name is indicator title: option, for example MACD Cross Events: Bullish cross, or indicator title: event title when Any is picked. Keep it, or give the alert your own name: the alerts list shows the event alert as the value condition it is stored as (see below), so the name is what tells event alerts apart.

How an event output is encoded

The output is stored as a numeric series, like any other plot: The alert dialog builds a regular value condition from it: Inside Channel from k - 0.5 to k + 0.5 for option k, and Greater Than 0.5 for Any or a single event. You only need these numbers when you read the output directly, for example through the Platform API, or set a value alert on it yourself. Because the encoding follows the order of options, adding an option to the end of the list keeps existing alerts valid, while reordering or removing options changes what they match.

Limitations of event outputs

  • Not drawn. An event output never appears on the chart and has no entry on the Style tab or in the Outputs list of the indicator settings. To also show the event, add a marker or a label.
  • Main returns the option name or None. A string literal that is not one of the options is a compilation error. A string computed at run time that matches no option stops the indicator with an error that names the output and the value.
  • One option per bar. An output reports at most one option on a bar. If two events can happen on the same bar and users need alerts on both, declare them as separate outputs.
  • Options rules. options must be written as a list literal right in the decorator, not as a module-level constant. It holds 2 to 32 distinct, non-empty string literals, each at most 64 characters, with no leading or trailing spaces. A list with one item is a compilation error: declare a single event instead.

Data outputs

Declare a data output with the @plot.data decorator:
  • id: a unique identifier of the output. It is also the name used in alert message placeholders.
  • title: the name users see in the alert dialog. If omitted, the id is used.
Main returns a bare number for it (float or int), the same value a line would take. Return nan on bars where there is no value. The indicator below draws an EMA and exposes a trailing stop and the ATR as data outputs:
The chart shows only the EMA. In the alert dialog, Long stop and ATR are listed next to EMA and take the usual value criteria. Their values can also go into the alert message with the {{cond<N>.main.<id>}} placeholder, for example Stop: {{cond0.main.stop}}, ATR: {{cond0.main.atr}} (see Variables in alert messages).
@plot.data replaces the old workaround of a @plot.line with pane, status_line and price_label all turned off in its display_options. Such a line still exists on the chart and in the Style tab; a data output does not.

Limitations of data outputs

  • Not drawn. A data output creates no chart series and has no entry on the Style tab. It shows no value in the status line or on the price scale, and does not affect the chart’s scale.
  • Numbers only. Main returns a bare float or int. Returning a plot.Line(...) object, or passing color= or display_options= to @plot.data, is a compilation error.
  • No fills. @plot.fill cannot reference a data output or an event output.