Forex Factory
  • Login

  • Username: Password:
  • 11:33pm

  • Search
  • Home

  • Forums

  • Trades

  • Calendar

  • News

  • Market

  • Brokers

Options

Search

Subscribe to Thread

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Convert afl file to mq4 file 4 replies

Reading a text file from within EA? 7 replies

MetaTrader 4, mq4 File to Esignal EFS File 0 replies

how to include a file.txt in an mq4 file ?? 6 replies

How can I use MetaEditor file? 1 reply

  • Platform Tech
  • /
  • Reply to Thread

Text file help

  • Post# 1
  • Quote
  • First Post: Dec 29, 2012 5:50pm
  • nondisclosure00
    Joined Apr 2007 | 591 Posts | Status: Gettin' kick in the nutz every day!
Writing data to a text file in mql4 is easy enough. Reading it back is a pain.

What I'm going to do is write a set of data at the top of every hour (for this example, we'll say Open, High, Low, Close, DateTime, SomeINT). Now, at the top of every hour, I don't want to add the data; I want to read what's in the file first, delete the data in the file, then write the new set of data. Data in the file will be from Bar[2] that will be deleted and the data written to the candle will be Bar[1].

Anyone got any ideas or links to good tutorials on how to do this? Google is letting me down today.

Thanks.
-Non.
  • Post# 2
  • Quote
  • Last Post: Dec 30, 2012 5:04am
  • RaptorUK
    Joined Jan 2008 | 602 Posts | Status: Member
Quoting nondisclosure00
Writing data to a text file in mql4 is easy enough. Reading it back is a pain.

What I'm going to do is write a set of data at the top of every hour (for this example, we'll say Open, High, Low, Close, DateTime, SomeINT). Now, at the top of every hour, I don't want to add the data; I want to read what's in the file first, delete the data in the file, then write the new set of data. Data in the file will be from Bar[2] that will be deleted and the data written to the candle will be Bar[1].
Not sure why you are having problems, it's pretty simple to do . . . just write the data to a CSV file and read back from the same. To write the data use FileOpen() with FILE_CSV|FILE_WRITE and this will open a new file even if one of the same name already exists, then use FileWrite() to write you values to the file . . . when you are done make sure you close the file with FileClose()

To read from the file open it using FILE_CSV|FILE_READ then use FileReadDouble() four times for the OHLC values, then use FileReadInteger() to get the datetime, and again to get the final int , again don't forget to close the file when you are done.
20 pips a day isn't too much to ask . . .
Thread Tools Search this Thread
Show Printable Version Show Printable Version
Email This Thread Email This Thread
Search this Thread:

Advanced Search

  • Platform Tech
  • /
  • Text file help
  • Reply to Thread
0 traders viewing now

©2013 Forex Factory, Inc. / Terms of Use / Privacy Policy

Forex Factory® is a registered trademark.

Connect

  • Facebook
  • Twitter
  • RSS

Company

  • About FF
  • FF Blog
  • Careers at FF
  • Advertising
  • Contact FF

Products

  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer

Website

  • Homepage
  • Search
  • User Guide
  • Member List
  • Online Now
  • Report a Bug