ChartnautDocs

Outlooks

An outlook draws a Forward Insight on the chart. Click one of the definition's events and the study's outlook draws what events like it went on to do, on the bars after that event: a target and a stop with their odds, a fan of where price usually went, the zone it tended to settle in, the release time that matters.

The numbers are the same ones the card shows. The outlook only places them for the event you clicked, using that event's price and ATR.

What you see when you click

  1. Every other event on the chart fades out, and a dashed line marks the one you clicked.

  2. The drawing sweeps in over the bars after the event. The card sits beside it as its legend: hover a row and the shape it describes lights up.

  3. Keep pins the drawing to the chart. Reject, Esc or a click on empty chart throws it away.

Panning and zooming never close it, so you can move the chart to read it. On a historical event the drawing sits over the candles that really followed, so you can see how the cohort's answer played out.

Keep stays greyed out when the outlook drew nothing for that event, for example when too few past events had the same setup. The card says so, with any reason the outlook gave.

Kept outlooks

A kept outlook stays exactly as it was drawn, on that definition, symbol and timeframe, until you remove it. It comes back after a reload, a symbol or timeframe switch and a different chartbook. It shows quietly, faded and without labels, until you hover it or its event.

Kept outlooks are managed from Insights, the button beside the bar countdown under each chart. It appears when a definition with a Forward Insight is on the chart, with the number of kept outlooks beside it.

In Insights

Does

Eye beside a definition

Hides or shows its outlooks on this symbol and timeframe.

Opens: Card / Outlook / Both

What clicking that insight's events opens.

A kept outlook's row

Hover to light it up, click to go to it, × to remove it.

Hide all, Clear on SP500 15m, Clear everything

Hide every outlook here, remove the ones on this chart, or remove every kept outlook on every chart.

Card, outlook or both

Each insight opens one of three things when you click its events:

  • Card: the numbers only.

  • Outlook: the drawing, with the rows the outlook adds.

  • Both: the drawing beside the full card.

An insight whose study has an outlook opens Both until you pick something else in Insights. One without an outlook opens its card.

Outlook and Both need a study with an outlook, and a horizon the chart can draw. When one is not available its choice is greyed out, and a click opens the card.

Writing an outlook

An outlook is a file called outlook.js beside the study's study.js. The easiest way to get one is to ask the agent to draw the insight on the chart. It writes the file, checks it on the study's dry run, and changes the study if the card does not carry the numbers the drawing needs.

The file is a one-shot indicator: meta({ mode: "once", outlook: { … } }), an onBar over the bars up to the event, and an onRunEnd that draws after it. ctx.outlook holds the clicked event, its card, its pin_cell row and the drawing kit:

meta({ shortName: "Barrier", kind: "overlay", mode: "once",
  outlook: { maxBars: 32, label: "Target before stop" } });

export function onBar(ctx) {}

export function onRunEnd(ctx) {
  const o = ctx.outlook, k = o.kit;
  const b = o.cell?.data?.barrier;
  if (!b) { ctx.say("No target and stop odds for this setup yet."); return; }
  k.barrier({
    target: { at: b.target, unit: "atr", block: "hit", medianBars: b.medianBars },
    stop: { at: b.stop, unit: "atr", p: b.pStop },
    n: o.cell.n,
  });
}

This draws a dashed target 1 ATR above the event and a dotted stop below it, each labelled with its odds and the number of past events behind them, for example Target · 62% · base 50% · n=40.

The numbers come from the study. In onFinish, give each pin_cell metric an id so the outlook can label with it, and put anything else the drawing needs in the cell's data:

ctx.popoverLayout.cell({
  dims: g.scope,
  n: g.rows.length,
  blocks: [ctx.popoverLayout.metric("Target before stop", hit, {
    id: "hit", unit: "%", scale: "fraction_0_1", baseline: baseHit,
    description: "Share of these events that reached +1 ATR before -0.5 ATR.",
  })],
  data: { barrier: { target: 1, stop: -0.5, pStop: stopRate, medianBars: 9 } },
});

data is plain JSON, at most 16 KB per cell. Publish it relative to the event, in ATR multiples, percentages and bars after the event, so the outlook can place it on any event.

meta.outlook

Option

Range

Meaning

maxBars

1 to 1000, required

The most bars after the event the outlook draws on.

lookback

1 to 5000

Bars of history up to the event that onBar walks.

minN

1 or more, default 15

The fewest past events a drawn number may rest on. Below it, the kit draws nothing and says so.

label

up to 80 characters

The outlook's name on the chart and in Insights.

reads

up to 10 result ids

Other results of the run the outlook reads, matched to the event.

siblingData

true or false

Whether the "same event, one dimension flipped" cards carry their data too.

Output ids starting outlook_ belong to the kit, and an outlook may not read the clock (Date.now() or new Date()).

Limits

  • Blind past the event. An outlook reads only up to the bar the event fired on, and that bar must have closed. A historical outlook shows what it would have said at the time.

  • Inside the window the study measured. The horizon is at most maxBars, at most the bars the chart keeps ahead of the last candle (800 on 15m, 200 on 1h, 50 on 4h, 200 on 1d, 28 on 1w, 6 on 1mo), and at most how far past its events the study's run read. A study that measures 6 hours ahead on 15m allows 24 bars. An insight with no horizon of its own draws as far as those limits allow. Set outlook_max_bars past one of them and it is refused.

  • One event at a time, on the insight's timeframe, on the price pane.

  • Frozen once kept. A kept outlook does not update as new bars print.

  • Numbers from the study. The card, the cell and declared reads. Nothing at click time searches history.

  • Data. The economic calendar has the schedule, forecast and previous figure, never the released figure, and lists releases up to 7 days ahead. Options levels for a day take effect the next morning, about 09:50 New York. Outlooks cannot read other instruments' candles.

  • Saved with the study. The agent in the app writes outlook.js; from the API or a connected AI app, include a file named outlook.js in the study's save_script files. It is checked and stored beside the study, never as one of its files, and a save without it leaves the outlook as it is. Once a study has one, show on update_forward_insight sets what a click opens.