Bring your own history — ticks or candles, CSV, Parquet, JSON Lines, MetaTrader's exports — into a laboratory, see exactly what each file changes, and add to it over the years without ever silently re-pricing a past trade.
01What a laboratory of your own files is
A laboratory of your own files holds market data you bring yourself: a broker's export, a data vendor's download, a file a colleague sent you, a series your own program wrote. It replays and trades like any laboratory: tick by tick, with rewind, on Bentrix's own venue. Nothing in it leaves your computer.
You can have as many as you like, each under the name you give it. One might hold "Broker A exports" and another "Index futures, cleaned". Make one from ☰ › File › New laboratory, then Your own files, and type its name. It starts empty. Make a workbench in it, then import a file into it.
You choose the account when you make the laboratory, as with any laboratory: its currency, opening balance, leverage, hedging or netting, and the time zone its candles are cut in (see the account).
02Importing, step by step
- In the workbench's Market Watch, press + and choose Import a data file…. Once the laboratory holds data, Market Watch's menu also has Import more data….
- Choose the file. The Import data sheet reads it, imports nothing yet, and shows what it found:
- what the file holds: ticks, or candles and their length (Candles M5);
- where its prices come from: bid and ask, traded prices or bid only;
- its rows, and the first and last moment it covers, in UTC;
- the first rows as written;
- The file's columns: what each column holds. Press a column to say otherwise.
- every fault it found, counted (below).
- Answer what the file cannot say for itself:
- Clock, hours from UTC: the offset of the file's times from UTC; 0 when they are UTC.
- The dates could be day-first or month-first: shown only when no date in the file proves which. Press Day first or Month first. Bentrix never guesses.
- The file holds several data files: shown for an archive of several. Pick one.
- Spread, in points: shown for a file of bids alone, or candles with no spread column.
- Into the market: the market it goes into. The name is read from a symbol column, or from the start of the file's name (
EURUSD_M5.csvgoes into EURUSD). For a market the laboratory does not hold yet, the sheet asks its facts (below). - Choose how it is added: Newer wins (the default) or Replace the days (below).
- Before you import, the sheet says exactly what it will change, day by day, for example 3 days: 1,320 added, 120 changed, 0 kept, 0 removed. It adds 87 minutes modelled from longer candles where it models minutes, and Some days will hold rows of more than one source where layers mix.
- Press Import. The first import onto an empty workbench takes the workbench to the file's days.
03What can be imported
Ticks: a time and a bid and an ask; or a traded price (last), filled at the next trade; or a bid alone, its ask made from the spread you give. A volume and flags are read if the file has them.
Candles: a time, open, high, low and close, and if the file has them a tick volume, a real volume and a spread. Any length: one minute, five, an hour, a day.
File formats:
- Delimited text, CSV and the like: any delimiter, quoted fields, a decimal comma, a thousands separator, with or without a header row. The delimiter is found by trying each candidate over the first rows: the one that splits every row into the same number of fields, and the most numeric ones, wins. You can correct it.
- Parquet, with any column names, mapped the same way.
- JSON Lines: one object a line.
- MetaTrader 5's exports, of ticks or of bars (their
<DATE>,<TIME>,<TICKVOL>,<SPREAD>headers are read like any other). - MetaTrader 4's
.hsthistory files. - A
.gzor.ziparound any of these, recognised by its contents, never by its name.
Text encodings: UTF-8 with or without a byte-order mark, UTF-16 in either byte order (with its mark), and Windows-1252 for an older file that is not UTF-8.
Refused, with what to do instead:
| File | What to do |
|---|---|
A spreadsheet (.xlsx, .xls) | Export it as CSV from your spreadsheet program |
MetaTrader's history cache (.hcc) | It is not a documented format; export the history from MetaTrader instead |
| A data vendor's own compressed binary tick files | Import an exported CSV instead |
04How the columns are read
With a header row, each column is read by its header's word. Case and every character but letters and digits are ignored, so <TICKVOL>, Tick Volume and tick_volume are one word:
| A header saying | Is read as |
|---|---|
| time, timestamp, datetime, ts, stamp, time msc, gmt time, local time, utc, dt, open time | time — a whole moment |
| date, day, trade date | date — with a time of day column beside it |
| open, o, open bid, bid open, open price | open |
| high, h, high bid, bid high, high price | high |
| low, l, low bid, bid low, low price | low |
| close, c, close bid, bid close, close price, adj close | close |
| tick vol, tick volume, ticks, tick count, count, number of trades, trades | tick_volume |
| real volume, real vol | real_volume |
| vol, volume, qty, quantity, size, amount | volume: a candle's traded volume in a file of candles, a tick's own in a file of ticks |
| spread | spread, in points |
| bid, bid price, best bid | bid |
| ask, ask price, offer, best ask | ask |
| last, price, last price, trade price | last, a traded price |
| flags, flag | flags |
| symbol, ticker, instrument, pair, market | symbol: the market of each row, in a file of several |
Any other header is not read. With no header, each column is read by its values. Either way, the sheet shows its reading and you can correct any column.
A file of several markets (a symbol column) is imported one market at a time: choose which of the file's markets goes into which of yours.
05Time stamps and clocks
A stamp may be written as:
- ISO 8601, with or without an offset:
2024-03-11T14:05:00Z,2024-03-11 14:05:00+03:30; - MetaTrader's
2024.03.11 14:05:00, or the compact20240311 140500; - a day first or a month first with the year last:
11/03/2024,03/11/2024; - a 12-hour clock:
2:05:00 PM; - fractional seconds, to the nanosecond;
- a date alone: a daily candle;
- epoch seconds, milliseconds, microseconds or nanoseconds, told apart by their count of digits;
- a date and a time of day in two columns.
Bentrix keeps every moment in UTC. A file written on another clock — a broker's server time, New York time — needs its offset: Clock, hours from UTC, such as 2 for a broker clock two hours east of UTC. An offset written in the stamp itself (+03:30, Z) wins over the file's clock.
A candle's length is read from the most common spacing between its stamps, and a file of dates alone is a daily file.
06What the reader finds, said and counted
Nothing is corrected silently. Every fault is listed with its count and the first line it was seen on:
| Found | What happens |
|---|---|
| Rows out of time order | sorted |
| Exact duplicate rows | dropped |
| Two different candles at one moment | the later one in the file is kept |
| A row whose time does not read | skipped and counted |
| A row whose prices do not read | skipped and counted |
| A candle whose high is under its low | kept, and named |
| A candle whose open or close is outside its high and low | kept, and named |
| A price at or below zero | kept, and named |
| A negative spread | kept, and named |
A file with no readable row at all, no column that reads as a price, or no column that reads as a time, is refused in one sentence saying which, for example no column reads as a time: map a time, or a date and a time of day.
07A new market's facts
The first import of a market the laboratory does not hold asks what a file cannot say. It starts from a currency pair's facts, at the file's own decimals. A six-letter name such as EURUSD gives its two currencies.
| Fact | What it is |
|---|---|
| Decimals | Decimals of a price, 0 to 8; the price's step is 10 to the minus this. Read from the file to start with |
| Lot | Units of the base in one lot, such as 100,000 for a currency pair or 1 for an index |
| Smallest volume | The smallest order, which is also the step between sizes |
| Base and Profit currency | The currency traded and the currency its profit is counted in |
| Trading hours, UTC | The hours it trades. A candle longer than a minute has its minutes laid inside them: an equity's daily candle fills its session, not the whole day. Empty is the whole day |
| Carry a night, points a lot | long and short: charged on a position held over each rollover, three times on the day you pick (Mon to Fri), as MetaTrader charges a swap in points. Both zero, no carry |
The facts are kept with the market. Later imports into it use them and do not ask again.
Markets in another currency
When a market's profit currency is not the account's, the sheet says how its money reaches the account:
- converts at its own price: the market is itself the rate, as USDJPY is for a JPY profit on a USD account;
- converts through EURUSD, at each minute: through another pair the laboratory holds, at that minute's rate;
- converts at the rate typed below, until a pair converting it is imported: you type a fixed rate (1 JPY = 0.0068 USD). It is used only until the laboratory holds a pair that converts it; from then on, the pair converts at each minute;
- nothing this laboratory holds converts it: import a pair that converts it (a JPY/USD pair on a USD account, or two pairs through USD on another account), or type a rate. Until then the market is charted and not priced.
08Candles longer than a minute
Bentrix replays minute by minute and tick by tick, so a coarser candle needs minutes inside it. They are modelled, and said:
- The path goes from the open to the nearer extreme, then to the other extreme, then to the close, in straight legs. Each leg takes minutes in proportion to the distance it travels.
- Every price is rounded to the market's step, and the extremes and the ends are the candle's own. Folding the minutes back gives the candle exactly: its open, high, low and close, and its volumes summed.
- The minutes are laid inside the market's trading hours.
- There is no randomness at all, so every computer models the same minutes.
The chart says modelled from D1 candles on such a day, and its hover explains what was modelled. A workbench over a daily file opens under Open prices only, one tick a candle, which models nothing. Choose another tick model on the Replay widget to replay the modelled minutes.
09Adding more later
Every import is kept as a batch: the file's own rows, unchanged, with its size, its fingerprint (sha256), when it was imported, how, and the Source you named (Where the file came from). The days a workbench reads are rebuilt from the batches, in order.
Newer wins (the default): where the new file has rows, they replace the older ones; where it has none, the older rows stay. This fills gaps and corrects what differs:
- ticks are matched at the instant: every row at an instant the new file covers is replaced by its rows there;
- candles are matched at the minute;
- ticks over candles: newer ticks win every minute they cover, and those minutes are folded from the ticks;
- candles over ticks: each minute is checked against the stored ticks. Where they agree, the minute keeps its real ticks; where they differ, it takes the newer candle and loses its ticks, and is modelled from the candle and marked. The sheet says 87 minutes of stored ticks differ from the candles and take them. The tape is never dropped whole;
- modelled minutes stand below every real row: real rows win at the instants they cover.
Replace the days: every day the file covers is cleared first, then filled from this file alone, the way a cleaned re-export removes a bad row.
Forgetting an import removes one batch and rebuilds the days it touched from the batches that remain. It is refused while a workbench that has traded stands on data that holds it; move that workbench first (below).
10Your past trades are never silently re-priced
A workbench that has traded keeps the data it traded on. When a later import rewrites some of its days, a card says Data under this workbench changed: EURUSD_2024.csv rewrote 3 of its days. This workbench still reads the data it traded on.
- Keep this workbench's data: it goes on reading what it traded on, and the card is put away.
- Move to the new data: the workbench is rebuilt from its record over the new days, and Bentrix shows what changed before it is kept: 4 deals filled at another price, 1 no longer fills; the balance went from 10,000.00 to 9,874.20.
- Keep the move makes it final; Undo puts the workbench back on its own data.
A workbench that has not traded simply reads the new days.
11From a program or an AI assistant
Every step of the sheet is a tool an agent or a program calls: import_lab_create, import_inspect (read a file and import nothing, with its columns, faults and first rows), import_run (the import, with the new market's facts, its trading hours, its carry and a fixed rate), import_ledger (every batch and every market's facts), import_forget, and bench_data (a pinned workbench's card: keep, move, keep the move, undo). The SDK guide on importing your own files walks through them in all nine languages.