Every method of client.study in the Python SDK.
attach#
Attach an indicator · tool study_attach
Attaches an indicator to a chart with its defaults — the person's saved default for the kind when there is one — as the indicator menu does; a custom study (custom:<id>) with its spec's defaults, or the inputs given. On, timeframe and wait_close set what it is computed on, as the settings card's Inputs tab does, for a built-in and a custom study alike; a timeframe the chart cannot read is refused by name. Answers the chart, the new study's id among its studies.
Declaration
client.study
def attach(self, chart: str, kind: str, *, convention: Optional[str] = None, inputs: Optional[Dict[str, Any]] = None, on: Optional[str] = None, timeframe: Optional[str] = None, wait_close: Optional[bool] = None) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | The chart's uri. |
kind | str | required | The indicator, as a chart's setup names it (setup.studies[].kind), e.g. Sma, ema, rsi, macd, bollinger, atr; a custom study as custom:<id> (catalogue/indicators lists them). |
convention | Optional[str] | optional | The calculation, where the kind has two: talib or mt5. |
inputs | Optional[Dict[str, Any]] | optional | A custom study's inputs by name, each within its spec's bounds; the rest take their defaults. |
on | Optional[str] | optional | On a chart built by price or activity, what it is computed on: elements (the default) or candles, the time candles behind them. |
timeframe | Optional[str] | optional | A timeframe of its own, as an interval is written (M5, H1, D1, …): the chart's or a longer one. Omitted, the chart's. |
wait_close | Optional[bool] | optional | With a timeframe of its own: true (the default) reads the last closed candle of it; false the one forming. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Recorded from a running Bentrix 0.1.382 on a laboratory of generated markets (long lists cut to their first rows):
{
"bench": "bentrix://lab/lab-1/bench/bench-2",
"detached": false,
"market": "SYN-DOCS",
"setup": {
"applied": "close",
"candles": {
"falling_body": [
239,
83,
80
],
"falling_border": [
239,
83,
80
],
"rising_body": [
38,
166,
154
],
"rising_border": [
38,
166,
154
]
},
"colour_defaults": 2,
"forecast": {
"arrival_marks": false,
"band_opacity": 0.18000000715255737,
"coarser": "spanned",
"diff": null,
"element_on_time": "auto",
"equivolume_width": "by_volume",
"finer": "folded",
"hidden": [],
"keep_after_realized": {
"horizons": 1
},
"on_profile": "forecast_session",
"opacity": 0.6000000238418579,
"other_rule": "derived",
"past_newest": "clock_time",
"readout": true,
"room": "forecast",
"samples_drawn": 32,
"show": true,
"time_on_elements": "derived",
"trail": 0,
"uncertainty": "fan"
},
"frame_colour": [
163,
169,
180
],
"grid": {
"choice": "automatic",
"colour": [
69,
75,
87
],
"step": 1.0
},
"layering": "candles-in-front",
"magnet": {
"on": true,
"px": 10.0
},
"news": {
"currencies": "market",
"shown": "off"
},
"objects": [],
"objects_bar": false,
"outputs": {
"hidden": [],
"zones": false
},
"period_colour": [
69,
75,
87
],
"periods": true,
"price": {
"ask": true,
"bid": true,
"countdown": true,
"last": "without_pair",
"prev_close": false,
"session_hl": false,
"spread_band": false,
"trade_chips": true
},
"shift_mark": true,
"shift_parked": 0.0,
"studies": [
{
"applied": "close",
"author": "agent:1",
"convention": "mt5",
"id": 1,
"kind": "rsi",
"settings": {
"period": 14,
"shape": "period"
}
}
],
"style": {
"activity": {
"volume_per_bar": 1000
},
"bars": {
"falling": [
239,
83,
80
],
"hlc": false,
"rising": [
38,
166,
154
],
"thickness": "px1"
},
"candles": {
"bodies": "filled",
"equivolume": false,
"ha_smoothing": 1,
"hollow": "both",
"volume_width": [
0.15000000596046448,
0.8999999761581421
],
"wick": "border"
},
"elements": {
"bodies": "filled",
"down": [
239,
83,
80
],
"kagi_reversal": {
"kind": "auto"
},
"kagi_source": "closes",
"kagi_thick_px": 2.5,
"kagi_thin_px": 1.0,
"line_break": 3,
"line_break_source": "closes",
"pnf_box": {
"kind": "auto"
},
"pnf_glyph": "letters",
"pnf_reversal": 3,
"pnf_source": "closes",
"range_box": {
"kind": "auto"
},
"range_source": "closes",
"renko_box": {
"kind": "auto"
},
"renko_forming": "partial",
"renko_reversal": 2,
"renko_source": "closes",
"renko_wicks": false,
"up": [
38,
166,
154
]
},
"line": {
"above": [
226,
229,
234
],
"area_fill": 25,
"baseline": "mean_of_shown",
"baseline_fill": 30,
"below": [
226,
229,
234
],
"colour": [
226,
229,
234
],
"column_down": [
239,
83,
80
],
"columExample
client.study.attach(chart, "rsi")build#
Stop or compute again an Assay study's build · tool study_build
Stops an Assay script study's build between two bars, as the square on its legend row does, or computes a stopped one again from its first bar, as the triangle does. A study that is not building, or not stopped, is refused by name. Answers the study's state: computing, stopped or ready.
Declaration
client.study
def build(self, chart: str, study: int, action: Literal["stop", "again"]) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
action | Literal["stop", "again"] | required | stop ends an Assay study's build between two bars; again computes a stopped one again from its first bar. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the study's state: computing, stopped or ready.
Example
client.study.build(chart, study, "…")define#
Define a custom study · tool study_define
Declares a custom study from a custom_study_spec, refused by name where the spec breaks a rule. An equal spec answers the same version; a different spec under the same id moves its version and every study of it on a chart is read again. Answers the kind to attach (custom:<id>) and the version.
Declaration
client.study
def define(self, spec: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
spec | Any | required | The spec, as custom_study_spec describes it. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Recorded from a running Bentrix 0.1.382 on a laboratory of generated markets (long lists cut to their first rows):
{
"kind": "custom:docs_range",
"version": 1
}Example
client.study.define("…")remove#
Remove an indicator · tool study_remove
Takes a study off its chart, and with it every study computed on its lines, as the legend's x does once its question is answered. Answers the chart.
Declaration
client.study
def remove(self, chart: str, study: int) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | The study's id, as the chart's answer gives it (setup.studies[].id). |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.remove(chart, study)reset#
Reset an indicator · tool study_reset
Puts a study back to the person's saved default for its kind, or to the kind's own when none is saved, as the settings card's Reset does. Answers the chart.
Declaration
client.study
def reset(self, chart: str, study: int) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | The study's id, as the chart's answer gives it (setup.studies[].id). |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.reset(chart, study)save_default#
Save an indicator as its kind's default · tool study_save_default
Saves a study's settings and looks as the default every new study of its kind opens with, or forgets that default, as the settings card's Defaults menu does. Answers the chart.
Declaration
client.study
def save_default(self, chart: str, study: int, *, forget: Optional[bool] = None) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
forget | Optional[bool] | optional | True forgets the kind's saved default instead, and puts this study back to the kind's own. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.save_default(chart, study)series_clear#
Drop a custom study's values · tool study_series_clear
Drops the values handed over for a custom study on a chart; the study stays, waiting for its script. Answers the chart.
Declaration
client.study
def series_clear(self, chart: str, study: int) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.series_clear(chart, study)series_get#
Read what a custom study draws · tool study_series_get
Reads what a chart draws now for a custom study — the values it holds, whoever computed them, at the bars it is drawn on as the chart last drew them — each line by its declared name with the newest limit values beside their bars' times; on a chart's elements (on: elements) each time is the element's candle open, beside its ordinal. A study on a timeframe of its own answers its values read back onto those bars. Nothing past the cursor. Answers waiting when nothing has landed.
Declaration
client.study
def series_get(self, chart: str, study: int, *, limit: Optional[int] = None) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
limit | Optional[int] | optional | The newest values kept per line (at most 5000). |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers waiting when nothing has landed.
Example
client.study.series_get(chart, study)series_put#
Hand over a custom study's values · tool study_series_put
Hands over a custom study's values, each at one of the bars it is computed on: the chart's bar opens; on a chart built by price, its elements (each by its candle's open and its ordinal, chart_elements_get) or, set to the candles, the candles' opens; with a timeframe of its own, that timeframe's bar opens, read back onto the chart under its wait_close. A time past the workbench's cursor, or one that is not such a bar, is refused by name; at most 5000 values a call. A put under another epoch replaces the series, and a study set to compute on other bars drops it; the values are drawn on the chart and never saved. Answers how many were accepted, the newest time held, and how many a move of the clock back had cut since the last put.
Declaration
client.study
def series_put(self, chart: str, study: int, epoch: int, times: List[int], lines: Dict[str, Any], *, append: Optional[bool] = None, ordinals: Optional[List[int]] = None) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | The chart's uri. |
study | int | required | The custom study's id on the chart. |
epoch | int | required | The program's own epoch: a put under another one replaces the whole series. |
times | List[int] | required | UTC milliseconds, oldest first, at most 5000: bar opens of what the study is computed on — the chart's interval, or on a chart built by price the candles behind it, or the study's own timeframe when it has one; on a chart's elements each element's candle open (chart_elements_get). |
lines | Dict[str, Any] | required | Every declared line by its name, one value per time; null is a gap. |
append | Optional[bool] | optional | True writes the newest value and after: the newest held is overwritten or followed. |
ordinals | Optional[List[int]] | optional | On a chart's elements only: each element's ordinal among the elements of its candle, one per time (chart_elements_get); omitted, every one 0. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers how many were accepted, the newest time held, and how many a move of the clock back had cut since the last put.
Example
client.study.series_put(chart, study, 1, "…", "…")set_bands#
Set an indicator's bands · tool study_set_bands
Sets the deviation bands around a single-line study and their looks, as the Bands tab does; bands null turns them off. Patch fields: bands, band_looks. Answers the chart.
Declaration
client.study
def set_bands(self, chart: str, study: int, patch: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
patch | Any | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.set_bands(chart, study, "…")set_inputs#
Set an indicator's inputs · tool study_set_inputs
Sets what a study computes — its calculation, prices, settings (a custom study's inputs by name), timeframe, whether it waits for the higher candle to close, on a chart built by price whether it is computed on the elements or the candles (on: "elements" or "candles"), and a function of two series' second series (second: {"from": "price", "price": "open"}, {"from": "volume"}, {"from": "market", "symbol": "EURUSD", "price": "close"}, {"from": "study", "of": place, "line": 0} or {"from": "fixed", "value": 14}) — as the settings card's Inputs tab does, for a built-in and a custom study alike. Patch fields: convention, applied, applied_also, settings, timeframe, wait_close, on, second. Answers the chart.
Declaration
client.study
def set_inputs(self, chart: str, study: int, patch: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
patch | Any | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Recorded from a running Bentrix 0.1.382 on a laboratory of generated markets (long lists cut to their first rows):
{
"bench": "bentrix://lab/lab-1/bench/bench-2",
"detached": false,
"market": "SYN-DOCS",
"setup": {
"applied": "close",
"candles": {
"falling_body": [
239,
83,
80
],
"falling_border": [
239,
83,
80
],
"rising_body": [
38,
166,
154
],
"rising_border": [
38,
166,
154
]
},
"colour_defaults": 2,
"forecast": {
"arrival_marks": false,
"band_opacity": 0.18000000715255737,
"coarser": "spanned",
"diff": null,
"element_on_time": "auto",
"equivolume_width": "by_volume",
"finer": "folded",
"hidden": [],
"keep_after_realized": {
"horizons": 1
},
"on_profile": "forecast_session",
"opacity": 0.6000000238418579,
"other_rule": "derived",
"past_newest": "clock_time",
"readout": true,
"room": "forecast",
"samples_drawn": 32,
"show": true,
"time_on_elements": "derived",
"trail": 0,
"uncertainty": "fan"
},
"frame_colour": [
163,
169,
180
],
"grid": {
"choice": "automatic",
"colour": [
69,
75,
87
],
"step": 1.0
},
"layering": "candles-in-front",
"magnet": {
"on": true,
"px": 10.0
},
"news": {
"currencies": "market",
"shown": "off"
},
"objects": [],
"objects_bar": false,
"outputs": {
"hidden": [],
"zones": false
},
"period_colour": [
69,
75,
87
],
"periods": true,
"price": {
"ask": true,
"bid": true,
"countdown": true,
"last": "without_pair",
"prev_close": false,
"session_hl": false,
"spread_band": false,
"trade_chips": true
},
"shift_mark": true,
"shift_parked": 0.0,
"studies": [
{
"applied": "close",
"author": "agent:1",
"convention": "mt5",
"id": 1,
"kind": "rsi",
"settings": {
"period": 21,
"shape": "period"
}
}
],
"style": {
"activity": {
"volume_per_bar": 1000
},
"bars": {
"falling": [
239,
83,
80
],
"hlc": false,
"rising": [
38,
166,
154
],
"thickness": "px1"
},
"candles": {
"bodies": "filled",
"equivolume": false,
"ha_smoothing": 1,
"hollow": "both",
"volume_width": [
0.15000000596046448,
0.8999999761581421
],
"wick": "border"
},
"elements": {
"bodies": "filled",
"down": [
239,
83,
80
],
"kagi_reversal": {
"kind": "auto"
},
"kagi_source": "closes",
"kagi_thick_px": 2.5,
"kagi_thin_px": 1.0,
"line_break": 3,
"line_break_source": "closes",
"pnf_box": {
"kind": "auto"
},
"pnf_glyph": "letters",
"pnf_reversal": 3,
"pnf_source": "closes",
"range_box": {
"kind": "auto"
},
"range_source": "closes",
"renko_box": {
"kind": "auto"
},
"renko_forming": "partial",
"renko_reversal": 2,
"renko_source": "closes",
"renko_wicks": false,
"up": [
38,
166,
154
]
},
"line": {
"above": [
226,
229,
234
],
"area_fill": 25,
"baseline": "mean_of_shown",
"baseline_fill": 30,
"below": [
226,
229,
234
],
"colour": [
226,
229,
234
],
"column_down": [
239,
83,
80
],
"columExample
client.study.set_inputs(chart, 1, "…")set_slope#
Set an indicator's slope colouring · tool study_set_slope
Sets how a single-line study is coloured by its slope and the colours of its five states, as the Slope tab does; slope null turns it off. Patch fields: slope, slope_look. Answers the chart.
Declaration
client.study
def set_slope(self, chart: str, study: int, patch: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
patch | Any | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.set_slope(chart, study, "…")set_style#
Set an indicator's lines' looks · tool study_set_style
Sets each line's colour, width, dash, kind and price line, the study's output and what it is computed on over an element chart, as the Style tab does. Patch fields: looks, output, on. Answers the chart.
Declaration
client.study
def set_style(self, chart: str, study: int, patch: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
patch | Any | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.set_style(chart, study, "…")set_visibility#
Set on which intervals an indicator is drawn · tool study_set_visibility
Sets on which intervals a study is drawn, as the Visibility tab does. Patch field: visibility. Answers the chart.
Declaration
client.study
def set_visibility(self, chart: str, study: int, patch: Any) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
chart | str | required | |
study | int | required | |
patch | Any | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the chart.
Example
client.study.set_visibility(chart, study, "…")undefine#
Forget a custom study's definition · tool study_undefine
Forgets a custom study a program defined. Refused while any chart holds a study of it, and for a script's: a script's study is the person's file. Answers the kind.
Declaration
client.study
def undefine(self, kind: str) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
kind | str | required | The custom kind, custom:<id>. |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Answers the kind.
Example
client.study.undefine("…")values#
Compute a study · tool study_values
Computes a study over a laboratory workbench's bars as its chart reads them at the cursor — never a bar past the clock — and answers each line by what it is, with the newest values beside their candles' times. An Assay indicator of the indicators folder is computed too, with no chart: study as custom:<id>, its inputs given or its defaults, each line by its declared name.
Declaration
client.study
def values(self, bench: str, symbol: str, timeframe: str, study: Any, *, inputs: Optional[Dict[str, Any]] = None, limit: Optional[int] = None) -> Dict[str, Any]Parameters
| Name | Type | What it is | |
|---|---|---|---|
bench | str | required | The laboratory workbench's uri. |
symbol | str | required | |
timeframe | str | required | The interval, as the menu writes it. |
study | Any | required | The study as a chart's setup files it (setup.studies[] in a chart's answer, without id), or "custom:<id>" for an Assay indicator of the indicators folder. |
inputs | Optional[Dict[str, Any]] | optional | An Assay indicator's inputs by name; those not given take its spec's defaults. |
limit | Optional[int] | optional | The newest values kept per line (at most 5000). |
Returns
Dict[str, Any] — the tool’s answer as a dict of plain values.
What it answers
Recorded from a running Bentrix 0.1.382 on a laboratory of generated markets (long lists cut to their first rows):
{
"cursor_ms": 1791892903523,
"lines": [
{
"line": "Main",
"values": [
51.68415901908286,
52.57435557385333,
52.7306736537927,
57.865591776766635,
57.4091548608301
]
}
],
"symbol": "SYN-DOCS",
"timeframe": "H1",
"times": [
1791878400000,
1791882000000,
1791885600000,
1791889200000,
1791892800000
]
}Example
client.study.values(bench, "SYN-DOCS", "H1", study)