Bentrix Docs
HomePricingDashboard

Python: charts

Every method of client.chart in the Python SDK.

arrange#

Arrange a workbench's charts · tool chart_arrange

scope: labplan: plussince 1.0.0

Tiles the workbench's chart windows that are not minimized, as the chart toolbar's Arrange does. Answers the windows' states.

Declaration

client.chart
def arrange(self, bench: str) -> Dict[str, Any]

Parameters

NameTypeWhat it is
benchstrrequiredThe workbench's uri.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the windows' states.

Example

client.chart.arrange(bench)

close#

Close a chart · tool chart_close

scope: labplan: plussince 1.0.0

Closes a chart window. A workbench's last chart is never closed, as on screen. Answers the workbench's charts left.

Declaration

client.chart
def close(self, chart: str) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequiredThe chart's uri, as get_state gives it at depth charts.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the workbench's charts left.

Example

client.chart.close(chart)

open#

Open a chart · tool chart_open

scope: labplan: plussince 1.0.0

Opens a chart window of one of the workbench's markets, as Market Watch's Chart window does: a market already charted comes to the front unless new_window asks for a second window. Answers the chart.

Declaration

client.chart
def open(self, bench: str, symbol: str, *, new_window: Optional[bool] = None, timeframe: Optional[str] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
benchstrrequiredThe workbench's uri.
symbolstrrequiredOne of the workbench's markets.
new_windowOptional[bool]optionalA second window of a market already charted, as the bar's new-window button opens.
timeframeOptional[str]optionalThe interval, as the menu writes it (M1 when absent).

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": [],
    "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
        ],
        "column_up": [
          38,
          166,
          154
        ],
        "column_width": 80,
        "columns_from": "zero",
        "high_low_marker": "at_close",
        "marker": "dot",
        "marker_every": 1,
        "thicknes

Example

client.chart.open(bench, "SYN-DOCS")

revert_type#

Put a chart's type back · tool chart_revert_type

scope: labplan: plussince 1.0.0

Puts the chart's type, price, style and price lines back as they were before the Chart type & price widget first edited it, as the widget's Revert does. Answers the chart.

Declaration

client.chart
def revert_type(self, chart: str) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequiredThe chart's uri, as get_state gives it at depth charts.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the chart.

Example

client.chart.revert_type(chart)

set_market#

Change a chart's market · tool chart_set_market

scope: labplan: plussince 1.0.0

Replaces the chart in its window by the same interval on another of the workbench's markets, carrying its type, studies and colours and none of its drawings, as the bar's market button does. The chart gets a new uri, which the answer gives.

Declaration

client.chart
def set_market(self, chart: str, symbol: str) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
symbolstrrequiredOne of the workbench's markets.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

What the tool's description says.

Example

client.chart.set_market(chart, "SYN-DOCS")

set_pane#

Set a chart's grid and magnet · tool chart_set_pane

scope: labplan: plussince 1.0.0

Sets what the chart's gear sets — the grid and its step and colour, the layering, the period marks and their colour, the frame's colour, the magnet and its radius, the economic calendar's releases and whose — each field optional. Answers the chart.

Declaration

client.chart
def set_pane(self, chart: str, *, frame_colour: Optional[List[int]] = None, grid: Optional[str] = None, grid_colour: Optional[List[int]] = None, grid_step: Optional[float] = None, layering: Optional[str] = None, magnet: Optional[bool] = None, magnet_px: Optional[float] = None, news: Optional[str] = None, news_currencies: Optional[str] = None, period_colour: Optional[List[int]] = None, period_marks: Optional[bool] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
frame_colourOptional[List[int]]optional
gridOptional[str]optionalAutomatic, every or off.
grid_colourOptional[List[int]]optional[r, g, b].
grid_stepOptional[float]optionalThe grid's step in price, with grid every.
layeringOptional[str]optionalWhich is drawn on top, as the setup writes it.
magnetOptional[bool]optionalWhether a point placed snaps to a candle.
magnet_pxOptional[float]optionalThe magnet's radius in screen pixels.
newsOptional[str]optionalThe economic calendar's releases marked on the chart: off, every, moderate (MetaTrader's moderate and high) or high.
news_currenciesOptional[str]optionalWhose releases: market (the market's own currencies) or every.
period_colourOptional[List[int]]optional
period_marksOptional[bool]optionalWhether the calendar's own boundaries are marked.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the chart.

Example

client.chart.set_pane(chart)

set_price_lines#

Choose a chart's price lines · tool chart_set_price_lines

scope: labplan: plussince 1.0.0

Turns the chart's price lines on or off — bid, ask, the last price, the spread band, the previous close, the day's high and low, the candle countdown, the book's chips on the scale — as the widget's PRICE section does. Answers the chart.

Declaration

client.chart
def set_price_lines(self, chart: str, price: Any) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
priceAnyrequiredFields of the chart's price lines, laid over setup.price: bid, ask, last, spread_band, prev_close, session_hl, countdown, trade_chips.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the chart.

Example

client.chart.set_price_lines(chart, "…")

set_timeframe#

Change a chart's interval · tool chart_set_timeframe

scope: labplan: plussince 1.0.0

Changes this chart's interval, as the interval menu does: a timeframe replaces the chart in its window (a new uri, in the answer), or range_points makes it Range bars of that many points. Exactly one of the two.

Declaration

client.chart
def set_timeframe(self, chart: str, *, range_points: Optional[int] = None, timeframe: Optional[str] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
range_pointsOptional[int]optionalInstead of an interval, Range bars of this many points (the menu's RANGES).
timeframeOptional[str]optionalThe interval, as the menu writes it: M1, M5, H1, D1, W1, MN1, a custom M95, seconds S30, ticks T100.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

What the tool's description says.

Example

client.chart.set_timeframe(chart)

set_type#

Change a chart's type and style · tool chart_set_type

scope: labplan: plussince 1.0.0

Sets the chart's type, the price a line follows and its style, as the Chart type & price widget does — each field optional — and copies them onto the workbench's other charts when apply_to_all asks. Chart_revert_type puts the chart back as it was before its first edit.

Declaration

client.chart
def set_type(self, chart: str, *, applied: Optional[str] = None, apply_to_all: Optional[bool] = None, baseline_at_last_close: Optional[bool] = None, style: Optional[Any] = None, type_: Optional[str] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
appliedOptional[str]optionalThe price a one-line type follows: close, open, high, low, median, typical, weighted.
apply_to_allOptional[bool]optionalThen the type, price, style and price lines copied onto every other chart of the workbench.
baseline_at_last_closeOptional[bool]optionalA Baseline's level set at the chart's latest close.
styleOptional[Any]optionalFields of the chart's style, laid over the style its setup holds (setup.style in the answer).
type_Optional[str]optionalThe type, as a chart's setup writes it: candlestick, ohlc_bars, hollow_candles, volume_candles, heikin_ashi, line, step_line, area, baseline, renko, range_bars, three_line_break, point_and_figure, kagi, tick_bars, volume_bars, hlc_bars, line_markers, columns, high_low_bars, tpo.

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
        ],
        "colum

Example

client.chart.set_type(chart)

set_view#

Scroll or zoom a chart · tool chart_set_view

scope: labplan: plussince 1.0.0

Scrolls or zooms a chart as its keys do, applied where the chart is drawn: a chart of the workbench in front, not minimized. To_end takes it back to the newest bar and holds it there.

Declaration

client.chart
def set_view(self, chart: str, act: Literal["scroll_back", "scroll_forward", "scroll_back_fast", "scroll_forward_fast", "to_start", "to_end", "zoom_in", "zoom_out", "bar_back", "bar_forward"], *, n: Optional[int] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
actLiteral["scroll_back", "scroll_forward", "scroll_back_fast", "scroll_forward_fast", "to_start", "to_end", "zoom_in", "zoom_out", "bar_back", "bar_forward"]requiredWhat the chart's own keys do: scroll a tenth of the window, a whole window, to either end, zoom, one bar.
nOptional[int]optionalHow many times.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

What the tool's description says.

Example

client.chart.set_view(chart, "…")

window#

Move a chart window · tool chart_window

scope: labplan: plussince 1.0.0

Activates, minimizes, maximizes, detaches or attaches a chart window, as its title bar does. Answers the chart.

Declaration

client.chart
def window(self, chart: str, action: Literal["minimize", "activate", "maximize_toggle", "detach", "attach"]) -> Dict[str, Any]

Parameters

NameTypeWhat it is
chartstrrequired
actionLiteral["minimize", "activate", "maximize_toggle", "detach", "attach"]required

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the chart.

Example

client.chart.window(chart, "…")

timeframe_custom#

Add or remove a custom interval · tool timeframe_custom

scope: labplan: plussince 1.0.0

Adds a custom interval to the interval menu, or removes one, as the menu's custom dialog and its row's x do; the list is the application's. Answers the custom intervals.

Declaration

client.chart
def timeframe_custom(self, *, range_points: Optional[int] = None, remove: Optional[bool] = None, timeframe: Optional[str] = None) -> Dict[str, Any]

Parameters

NameTypeWhat it is
range_pointsOptional[int]optional
removeOptional[bool]optionalTrue takes it out of the menu; false adds it.
timeframeOptional[str]optionalThe interval as the menu writes it (M95, H5, S45, T250) — or range_points.

Returns

Dict[str, Any] — the tool’s answer as a dict of plain values.

What it answers

Answers the custom intervals.

Example

client.chart.timeframe_custom()

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed