How Stream MT4 Data into Excel per candle wise?

 

I am able to manually export mt4 historical data for forex EUR/USD as a csv file. However, i run my excel spreadsheet for calculation and would dearly love the hourly candlestick prices to come in automatically. (Open High Low Close Vol)

Anyone able to suggest?

 
creativesoln:

I am able to manually export mt4 historical data for by Browse to Save">forex EUR/USD as a csv file. However, i run my excel spreadsheet for calculation and would dearly love the hourly candlestick prices to come in automatically. (Open High Low Close Vol)

Anyone able to suggest?


anyone?
 

Use DDE


Edit: your question is almost the same as the OP verbatim from 8 years ago ;)

link

"How could I export live data to Excel from MetaTrade? I would like to export Open, High, low and Close, also Vol and time to a excel worksheet."

yours

"However, i run my excel spreadsheet for calculation and would dearly love the hourly candlestick prices to come in automatically. (Open High Low Close Vol)"

 

i need something like this to come in automatically, so that my excel can keep updating without me having to paste the csv file hourly.






open high low close vol
2011.12.27 20:00 1.30746 1.30763 1.30703 1.30729 611
2011.12.27 21:00 1.30731 1.30752 1.30661 1.30661 614
2011.12.27 22:00 1.30667 1.30733 1.30653 1.30666 634
2011.12.27 23:00 1.30668 1.30722 1.30659 1.30699 555
2011.12.28 00:00 1.30687 1.30749 1.30642 1.30674 473
 

So you need a history of hourly OHLCV?

That's easy to do using file functions in MQL.

bool IsNewBar()
{
   //each tick, check if it's a new 1 hour candle

   static datetime barTime;
   bool result = false;
   
   if(barTime != iTime(NULL,PERIOD_H1,0))
   {
      barTime = iTime(NULL,PERIOD_H1,0);  
     //you'll need to create a function to populate arrOHLCV     
     WriteToExcel("myHistory.csv", arrOHLCV[]);
     result = true;
   }
   
return(result);
}

Create an array with all the info you need and write to excel:

void WriteToExcel(string fileName, string arrayToWrite[]) 
{
   int handle = FileOpen(fileName, FILE_CSV|FILE_WRITE|FILE_READ, ',');
   for(int i = 0; i < ArraySize(arrayToWrite); i++) FileWrite(handle, arrayToWrite[i]);
   FileClose(handle);

return;
}
 
FlatFap:

So you need a history of hourly OHLCV?

That's easy to do using file functions in MQL.

Create an array with all the info you need and write to excel:


hi im new to programing where do i put this code :(
 
FlatFap:

So you need a history of hourly OHLCV?

That's easy to do using file functions in MQL.

Create an array with all the info you need and write to excel:


dear sir

sorry  for my ignorance in Mql but am good in excel and has the strong need also to get ohlc to come in to excel automatically and by period, i.e each candle's data to be filled in a new row in excel 

so how to use this mql code exactly please (as i know nothing about programing, and am really sorry for that). 

regards