Get from Ico-github-logo

Highlights from

  • metastockread(fullpath)
    METASTOCKREAD Read metastock files (symbols index files: master, emaster, xmaster; data files: .dat and .mwd)
  • View all files
4.5 | 4 ratings Rate this file 15 Downloads (last 30 days) File Size: 1.43 MB File ID: #28664 Version: 1.7
image thumbnail



Oleg Komarov (view profile)


08 Sep 2010 (Updated )

Read metastock files (master, emaster, xmaster and .dat/.mwd)

| Watch this File

File Information

Read metastock files (symbols index files: master, emaster, xmaster; data files: .dat and .mwd; no .dop support)
(1) METASTOCKREAD Read the symbols index file selected with uigetfile and import the data
(2) METASTOCKREAD(FULLPATH) Read the file specified by FULLPATH

OUT = metastockread(...)
OUT is a "m by 1" NON-scalar structure, where "m" is the # of .dat/.mwd files in the same directory of the symbol index files.

The (sub)scalar structure has the following fields:
- datNum : # of the .dat/.mwd file with the data
- symbol : security symbol
- name : security name
- inDate : initial date as 'yyyy-mm-dd'
- fiDate : final date as 'yyyy-mm-dd'
- freq : time freq. of the data I (intraday), D (daily), W, M, Q or Y
- idFreq : intraday time frequency in minutes
- data : time series data with variable number of fields (columns)

The data field columns follow the schema:

| Date/Time | Open | High | Low | Close | Volume | OpenInterest |

For details see help
For examples see the attached image.

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.

No tags are associated with this file.

Please login to add a comment or rating.
Comments and Ratings (12)
27 Mar 2015 Oleg Komarov

Oleg Komarov (view profile)

Thanks for reporting Richard and Goryn. I'll see when I can port it on github and fix those problems.

Comment only
10 Mar 2015 Richard

Made the following change to lines 118-119 to get the code to work in R2015a:

if Out(1).datNum < 256; fmt = 'F%d.DAT\n';
else fmt = 'F%d.MWD\n'; end

changed to:

if Out(1).datNum < 256; fmt = 'F%d.DAT';
else fmt = 'F%d.MWD'; end

Not sure what the compatibility issue is here.
Maybe someone else can explain?

Comment only
06 Jan 2014 Goryn

Goryn (view profile)

Very useful, thank you! I've found an error on line 156 and 158. Variable 'm' should be changed for 'mn' (minutes) or it overwrites variable 'm'(months) and causes error with intraday data.

Comment only
06 Jan 2014 Goryn

Goryn (view profile)

04 Mar 2012 James Kunce

Thank you!! Exactly what I was looking for and works great.

09 Dec 2010 cheng

cheng (view profile)

just i want;so thanks

03 Nov 2010 Oleg Komarov

Oleg Komarov (view profile)

I will look into the problem after the 12th of nov.
I hope I'll be able to write a metastockwrite function, in the meantime you can use the solution suggested by Tony.

Comment only
03 Nov 2010 Tony Tran

For whose who need to export to Metastock format
Step 1: output to text format, see the example

% format AAM,20100913,24.40,24.90,23.70,24.00,13600,0
fid = fopen('scindex.txt','w');
for i=1:size(SCIndex)
fprintf(fid, 'SCINDEX,%s,%.2f,%.2f,%.2f,%.2f,0\n',sdate,SCIndex(i),SCIndex(i),SCIndex(i),SCIndex(i));

Then call external program to convert the text file to MS. asc2ms can be found easily by google.

% execute
dos('asc2ms -r recordReplace -f "scindex.txt" -o "D:\MetaStock Data\VNINDEX"');

Comment only
29 Oct 2010 Han Oostdijk

nice well structured example of reading binary data.

27 Oct 2010 Shailesh Joshi

I will be happy to have program which will write data in metastock format. Mostly I convert it after downloading manually.

Comment only
09 Oct 2010 Oleg Komarov

Oleg Komarov (view profile)

I may if there's request.

Comment only
07 Oct 2010 Shailesh Joshi

By any chance do you have program to write to metastock format?

Comment only
09 Sep 2010 1.1

Added link to FEX page, edited example and edited description.

03 Aug 2011 1.2

Added fix for buggy *.dat files as pointed out by Davide Dalmasso

03 Aug 2011 1.3

Added fix for buggy *.dat files as pointed out by Davide Dalmasso

19 Feb 2012 1.4

Fixed erroneous date conversion for intraday series. As pointed out by Luca LPr the month had the same value as minutes due to same name of the variable.

19 Feb 2012 1.5

Uploaded wrong file.

17 Oct 2013 1.6

 - Cross platform compatible filepath handling (thanks to Thiago Tavares for reporting)
- got rid of dataread for forward compatibility

17 Aug 2015 1.7

Fixes suggeste dby Richard and Goryn, ported to github

Contact us