• Overview
  • Reviews
  • Comments
  • What's new

Direct export to matlab

Use this script to export the price history to MATLAB mat files from any chart. Optionally, a CSV file can be created. This script allows easily creating and verifying your trading strategy in MATLAB, for example, statistical arbitrage or pairs trading strategies.


Input parameters

  • startDT: start export from this date and time. Can be '1970.01.01 00:00:00' to start from the first available date and time.
  • endDT: the last date and time in the file. Can be '1970.01.01 00:00:00' to export until the most recent available date and time.
  • tryDownloadHistory: try to download history if there is no corresponding history in the terminal.
  • writeCSV: create CSV file as well.

Then simply open the created mat file in MATLAB. Variable name created in MATLAB corresponds to exported symbol name and timeframe. If there are special symbols in the instrument name, then they are replaced with "_".

The resulting variable has a matrix structure, where the columns are values of the corresponding parameters below:

Matlab serial date number(datenum), Open, High, Low, Close, Tick volume, Spread, Real volume.

To simplify access to corresponding time series scalar, index variables are created: itime, iopen, ihigh, ilow, iclose, itick_volume, ireal_volume. For example, they can be used to plot the chart of Close price relative to time in MATLAB (assuming EURUSD_M1 is the corresponding variable):

plot(datetime(EURUSD_M1(:, itime),'ConvertFrom','datenum')), EURUSD_M1(:, iclose));

The format of CSV file is: Date, Time, Open, High, Low, Close, Tick volume, Spread, Real volume.

No reviews
Version 1.1 - 2017.05.31
Error with startDT and endDT has been corrected.