Feeds as inputs
A feed is a series published on OpenMarket under an address, @scope/name:
an air quality reading every hour, a city's temperature, a daily total.
An
indicator reads a feed like any other source (Data sources):
one input declaration, read in onBar() through in_<name>(), lined up
on the chart's own bars.
Declaring a feed
text
input("close", ohlcv.close); // the chart's own candles: the bars
input("aqi", series.value, { ref: "@perceptlabs/kl-aqi", missing: "carry" }); // the feed, by its address| Part | What it is |
|---|---|
series.value | The feed's reading: its first value key. |
ref | The feed's address, @scope/name. Required. |
missing | "carry" (the default) repeats the last reading on a bar without one; "nan" leaves that bar empty. |
The sheet records the input as
{ "source": "series", "field": "value", "ref": "@perceptlabs/kl-aqi", "missing": "carry" }.
A feed is never the first input: the chart's own candles come first and set
the bars every reading lands on.
How readings land on bars
- A bar reads the last reading published inside it, on the chart's interval in UTC.
- Under
"carry", a bar with no reading repeats the last one, and the reading just before the loaded window seeds the first bars. - Under
"nan", a bar with no reading readsNaNand draws nothing: the right policy for events, where a quiet bar means nothing happened. - A feed that publishes faster than the chart's bars shows its last reading
per bar; a slower one carries between readings, or leaves gaps under
"nan".
Where a feed is read
| Where | What it reads |
|---|---|
| The chart | @scope/name feeds, on 1m, 5m, 15m, 30m, 1h, 4h, 1D and 1W charts |
| OpenMarket's cloud | the same feeds, for an indicator running there |
| Your OpenMarket runner | the same feeds, plus watch/, a series one of your watches keeps |
Refusals
The chart names the reason before it fetches anything:
| The chart says | Because |
|---|---|
| feeds read on 1m, 5m, 15m, 30m, 1h, 4h, 1D and 1W charts | the chart's interval is not one feeds are read on |
| a watch series reads on your OpenMarket runner | the ref is a watch/ series |
| state feeds are not numeric | the feed publishes states, not numbers |
| has no readings yet | nothing has been published to the feed so far |
Starting points
The template picker's Feeds group holds three complete indicators (The editor):
| Card | Reads | Draws |
|---|---|---|
Feed with an alert line (feed-alert-line) | @perceptlabs/ | the feed as a line, an alert line at a level you set, the feed shaded above it and a mark on each cross up |
Feed events as labeled dots (feed-events) | @perceptlabs/ | a faint column per reading and a labeled dot on every reading from a smallest value up |
Feed status card (feed-status-card) | @perceptlabs/ | a card with the last reading, how long ago it changed and whether the feed is live, lagging or stale |
Change ref to read another feed; the rest of the file follows it.