Every method of client.study() in the Rust 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()
pub fn attach(&self, args: StudyAttachArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | The chart's uri. |
kind | impl Into<String> | 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 | impl Into<String> | optional | The calculation, where the kind has two: talib or mt5. |
inputs | impl Into<Value> | optional | A custom study's inputs by name, each within its spec's bounds; the rest take their defaults. |
on | impl Into<String> | 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 | impl Into<String> | 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 | bool | optional | With a timeframe of its own: true (the default) reads the last closed candle of it; false the one forming. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
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(mcp::StudyAttachArgs::new(chart.clone(), "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()
pub fn build(&self, args: StudyBuildArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
action | impl Into<String> | required | stop ends an Assay study's build between two bars; again computes a stopped one again from its first bar. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the study's state: computing, stopped or ready.
Example
client.study().build(mcp::StudyBuildArgs::new(chart.clone(), study.clone(), "…"))?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()
pub fn define(&self, args: StudyDefineArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
spec | impl Into<Value> | required | The spec, as custom_study_spec describes it. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
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(mcp::StudyDefineArgs::new("…"))?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()
pub fn remove(&self, args: StudyRemoveArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | The study's id, as the chart's answer gives it (setup.studies[].id). |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().remove(mcp::StudyRemoveArgs::new(chart.clone(), study.clone()))?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()
pub fn reset(&self, args: StudyResetArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | The study's id, as the chart's answer gives it (setup.studies[].id). |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().reset(mcp::StudyResetArgs::new(chart.clone(), study.clone()))?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()
pub fn save_default(&self, args: StudySaveDefaultArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
forget | bool | optional | True forgets the kind's saved default instead, and puts this study back to the kind's own. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().save_default(mcp::StudySaveDefaultArgs::new(chart.clone(), study.clone()))?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()
pub fn series_clear(&self, args: StudySeriesClearArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().series_clear(mcp::StudySeriesClearArgs::new(chart.clone(), study.clone()))?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()
pub fn series_get(&self, args: StudySeriesGetArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
limit | i64 | optional | The newest values kept per line (at most 5000). |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers waiting when nothing has landed.
Example
client.study().series_get(mcp::StudySeriesGetArgs::new(chart.clone(), study.clone()))?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()
pub fn series_put(&self, args: StudySeriesPutArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | The chart's uri. |
study | i64 | required | The custom study's id on the chart. |
epoch | i64 | required | The program's own epoch: a put under another one replaces the whole series. |
times | Vec<i64> | 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 | impl Into<Value> | required | Every declared line by its name, one value per time; null is a gap. |
append | bool | optional | True writes the newest value and after: the newest held is overwritten or followed. |
ordinals | Vec<i64> | 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
Result<Value, Error> — the tool’s answer as a serde_json::Value.
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(mcp::StudySeriesPutArgs::new(chart.clone(), study.clone(), 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()
pub fn set_bands(&self, args: StudySetBandsArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
patch | impl Into<Value> | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().set_bands(mcp::StudySetBandsArgs::new(chart.clone(), study.clone(), "…"))?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()
pub fn set_inputs(&self, args: StudySetInputsArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
patch | impl Into<Value> | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
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(mcp::StudySetInputsArgs::new(chart.clone(), 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()
pub fn set_slope(&self, args: StudySetSlopeArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
patch | impl Into<Value> | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().set_slope(mcp::StudySetSlopeArgs::new(chart.clone(), study.clone(), "…"))?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()
pub fn set_style(&self, args: StudySetStyleArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
patch | impl Into<Value> | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().set_style(mcp::StudySetStyleArgs::new(chart.clone(), study.clone(), "…"))?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()
pub fn set_visibility(&self, args: StudySetVisibilityArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
chart | impl Into<String> | required | |
study | i64 | required | |
patch | impl Into<Value> | required | Fields of the study's entry (setup.studies[] in the chart's answer) laid over it; only this tab's fields. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the chart.
Example
client.study().set_visibility(mcp::StudySetVisibilityArgs::new(chart.clone(), study.clone(), "…"))?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()
pub fn undefine(&self, args: StudyUndefineArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
kind | impl Into<String> | required | The custom kind, custom:<id>. |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
What it answers
Answers the kind.
Example
client.study().undefine(mcp::StudyUndefineArgs::new("…"))?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()
pub fn values(&self, args: StudyValuesArgs) -> Result<ValueParameters
| Name | Type | What it is | |
|---|---|---|---|
bench | impl Into<String> | required | The laboratory workbench's uri. |
symbol | impl Into<String> | required | |
timeframe | impl Into<String> | required | The interval, as the menu writes it. |
study | impl Into<Value> | 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 | impl Into<Value> | optional | An Assay indicator's inputs by name; those not given take its spec's defaults. |
limit | i64 | optional | The newest values kept per line (at most 5000). |
Returns
Result<Value, Error> — the tool’s answer as a serde_json::Value.
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(mcp::StudyValuesArgs::new(bench.clone(), "SYN-DOCS", "H1", study.clone()))?