SyncHistorySQL
- ユーティリティ
- Maxim Kuznetsov
- バージョン: 1.0
Script for quick updates (synchronization) trade history in the SQLite database. Saves closed positions and orders, symbols data.
Take advantage of SQLite's capabilities for intermediate data storage, analytics, and integrations of the MetaTrader platform. Keep all your data in one place.
Use the saved data in SQL analytical queries, from Python and other languages, to build dashboards
Parameters
- useDefaults true - use default parameters. Save data to the COMMON hierarchy, to the db/ram/{server_name} directory.{account number}.trade.db
you can specify useDefaults=false and set your own save options:
- useCommon - use the COMMON hierarchy or the data directory of the current terminal
- useFolder - directory to save the database
- useFilename - the name of the database inside the directory
Database schema
The database contains the necessary minimum, in the style of mt4 and adapted for frequent inserts. After creating the database with the script, you can make your own adjustments to it (add indexes, computable fields, additional data and tables)
CREATE TABLE IF NOT EXISTS History ( ticket INT PRIMARY KEY, symbol VARCHAR(16), 'type' VARCHAR(16), lots REAL, openPrice REAL, stopLoss REAL, takeProfit REAL, price REAL, 'time' DATETIME, closeTime DATETIME, expiration DATETIME, profit REAL, swap REAL, commission REAL, magic INTEGER, 'comment' VARCHAR(255) ) WITHOUT ROWID;
and
CREATE TABLE IF NOT EXISTS Symbol ( name VARCHAR(16) PRIMARY KEY, base VARCHAR(16), quote VARCHAR(16), digits INTEGER, point REAL, tickSize REAL, minLot REAL, maxLot REAL, lotStep REAL ) WITHOUT ROWID
Using
Just run the script when you need to get the data.