NexusFi: Find Your Edge


Home Menu

 





Record live data to save as external text file (EA MT4)


Discussion in Platforms and Indicators

Updated
    1. trending_up 5,040 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Kalisto
Geneva, Switzerland
 
Posts: 64 since Dec 2015
Thanks Given: 74
Thanks Received: 26

I know that such tool exists at least for NinjaTrader as a strategy which acts as a recorder of live market tick data that saves it in real-time in text files. Of course, formatting outputs can be configured as parameters, as well with the right input separators (maybe even format templates to remember)

I am obliged to work with MT4 for a project and I am wondering if such EA or similar already is available for MT4 ?
(to me the M1 data export function within MT4 is not enough, does not do the trick)

Thanks for your help


Reply With Quote

 
  #2 (permalink)
Kalisto
Geneva, Switzerland
 
Posts: 64 since Dec 2015
Thanks Given: 74
Thanks Received: 26

I can't believe it does not exist ! Anyone please ?


Reply With Quote
  #3 (permalink)
maryfromcolorado
Denver CO USA
 
Posts: 32 since Sep 2016
Thanks Given: 0
Thanks Received: 13


Probably not, but I wrote something similar. easy to write. really. Just from memory.

Just use 3 arrays

double Bids[100];
double Asks[100];
uint TickCounts[100];

int iIndex = 0;

OnTick()
{

StoreTick(Bid, Ask, GetTickCount());

}
StoreTick(double b, double a, uint t)
{
if (iIndex == 100)
DumpPrices();
Bids[iIndex] = b;
Asks[iIndex]= a;
TickCounts[iIndex] = t;
iIndex++;
}
DumpPrices()
{
string fileName = Symbol()+"_"+TimeToStr(TimeCurrent(), TIME_DAY)+".csv"
ResetLastError();
int file_handle=FileOpen(fileName, FILE_READ|FILE_WRITE|FILE_CSV);
if(file_handle!=INVALID_HANDLE)
{
FileSeek(file_handle, 0, SEEK_END);
for(int i=0;i<iIndex;i++)
{

Print(NormalizeDoublt(Bids[i],Digits),NormalizeDouble(Asks[i],Digits),TickCounts[i]);

}
//--- close the file
FileClose(file_handle);
PrintFormat("Data is written, %s file is closed",fileName);
}
void OnDeinit(const int reason)
{
DumpPrices();

}


Reply With Quote
Thanked by:
  #4 (permalink)
 rosasurfer 
Sofia Bulgaria
 
Experience: Intermediate
Platform: MetaTrader, MultiCharts
Trading: Forex, ES, GC, strange synthetic creatures
Posts: 39 since Nov 2014
Thanks Given: 41
Thanks Received: 34

Yes, for a programmer this is not difficult. However, recording to (and later reading from) a text file is a quite unprofessional approach (looking at you, MultiCharts). The data amount aggregated quickly becomes to large for text files. So the format has to be binary and MT4 supports read/write access to the binary data format of its database. Not so MT5, Multicharts or NinjaTrader.

As an actual example of how-to-do have a look at the following codes:

https://sites.google.com/site/prof7bit/offline_charts-mqh

This is one example and shows the general approach. A complete recorder records all timeframes at once and saves them as real instruments, not as offline charts. But the data format and reading/writing it is exactly the same as in the above example.

Best

edit: You are not restricted to standard timeframes but can read/write whatever you wish, e.g. 5-seconds charts or 2-minutes charts.


Reply With Quote




Last Updated on November 7, 2016


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts