Zoom the chart

Changed

set_visible_rangeChanges the chartSafe to repeat

The app zooms your chart to a period, for example March to May 2022, so you see the bars it is talking about.

Details#

Zoom the member's chart to a period: set which bars it shows, left to right. Use it to show the member the bars you are talking about. Pass exactly one of: from and to (a date range), bars (the newest bars), or reset true (the chart's default view: the newest 120 bars). The chart shows the bar that contains from through the bar that contains to, each whole on screen, with padding_bars empty bar widths on each side (default 1), and at least 2 bars. Only the time axis changes. The price axis is not changed (with Auto on it fits the bars in view, as when the member zooms), nothing is saved to the layout, and the member can zoom and scroll freely afterwards. It works on the chart the member is viewing: omit symbol, venue, timeframe and layout to use it, or pass the same ones as that chart. When the member is viewing another market, timeframe or layout, the call is refused with chart_not_shown: call open_chart with that market and timeframe first, then call this again. The bars are the chart's own history, loaded like the chart loads it. A start before that history starts at its first bar, and an end after the newest bar ends at the newest bar; clamped says which (start, end, min_bars). A range entirely outside the history is refused with range_outside_history, and detail has history_start and history_end. 1D, 1W and 1M charts hold the market's full history; 1H and 4H hold a shorter recent history (history_start says where it begins), so for an older period use 1D or 1W. The answer has applied (first_bar, last_bar, bars, padding_bars, and from and to: the exact window sent to the chart, in UTC), clamped, history_start, history_end, and chart: sent (the open chart tab got it) or waiting (no chart tab is connected right now, for example while it reconnects after a layout switch; the first chart tab that connects on that layout within 30 seconds applies it). To find a period first (for example the last time a market had 8 red weekly candles in a row), compute it with run_bullscript, then call this with its dates. Example, March to May 2022 on BTC/USDT 1W: {"symbol": "BTC/USDT", "venue": "BINANCE", "timeframe": "1W", "from": "2022-03-01", "to": "2022-05-31"}. Example, the newest 200 bars of the chart on screen: {"bars": 200}. Example, back to the default view: {"reset": true}.

Inputs#

NameTypeRequiredDescription
symbolstringOptionalTicker or pair, for example BTCUSDT or AAPL.
venuestringOptionalOptional venue, for example BINANCE, COINBASE, BITSTAMP or NASDAQ. BINANCE is Binance spot, not Binance futures.
kindstringOptionalOptional. spot or perp. Omit to open a spot market. Perpetuals are only opened when kind is perp or the venue is a futures venue.
timeframestringOptionalOne of 1H, 4H, 1D, 1W, 1M. Example: 1D.
layoutstringOptionalLayout name from list_layouts, or "Default" (the member's own chart). Omit to use the layout the member has open, or Default when no chart is open.
fromstring or numberOptionalStart of the period: a UTC date "2022-03-01" (00:00 UTC), a UTC date and time "2022-03-01 14:00", an ISO 8601 time with an offset, or unix seconds (not milliseconds). The view starts at the bar that contains it. Send with to.
tostring or numberOptionalEnd of the period, in the same formats as from. A date alone means the end of that UTC day, so to 2022-05-31 includes 31 May. The view ends at the bar that contains it. Send with from.
barsintegerOptionalInstead of from and to: show the newest this many bars (2 to 5000), ending at the bar still forming. Example: 200.
padding_barsintegerOptionalEmpty bar widths left of the first bar and right of the last bar, 0 to 100. Default 1. Not with reset. Default: 1.
resetbooleanOptionaltrue puts the chart back to its default view: the newest 120 bars and a few empty bars on the right. Send it alone.