MT5 Rates Live Feed for Excel

 

Hello there,


I wanted to ask if there is a way to pull Live data from MT5 on Excel sheet.

Any help will be greatly appreciated. 

 

There is summary post (with articles, CodeBase tools and key threads with toold and with about HowTo), so
you can select something from there: post

Working with Excel (tools, indicators, conversion ...)
Working with Excel (tools, indicators, conversion ...)
  • 2022.10.06
  • www.mql5.com
Hi again, The Multiple Regression Analysis and Forecasting template provides a solid basis for identifying value drivers and forecasting time serie...
 
Dimitri:

Hello there,


I wanted to ask if there is a way to pull Live data from MT5 on Excel sheet.

Any help will be greatly appreciated. 

Hello 

Use this EA for testing 

#property copyright "Read the discussion"
#property link      "https://www.mql5.com/en/forum/450611"
#property version   "1.00"

//we create a global handle for the file
  int myFile=INVALID_HANDLE;
  string excelSeparator="\t";
  ulong defaultPosition=0;
int OnInit()
  {
//---
  //we load the csv file or create it (you can create xls files if you know too)
    myFile=FileOpen("myExcel.csv",FILE_SHARE_READ|FILE_WRITE|FILE_TXT); 
    if(myFile==INVALID_HANDLE){return(INIT_FAILED);}
    defaultPosition=FileTell(myFile);
    Comment("DefaultPosition("+IntegerToString(defaultPosition)+")");
    //if we succeed we start a timer to simulate re writes to the file 
      EventSetTimer(1);
//---
   return(INIT_SUCCEEDED);
  }
void OnTimer(){
  //go to start of file 
  FileSeek(myFile,defaultPosition,SEEK_SET);
  uint b=FileWriteString(myFile,"TimeInMT5"+excelSeparator+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS));
  FileFlush(myFile);
  Print("Written "+IntegerToString(b));
  }

void OnDeinit(const int reason)
  {
//---
  if(myFile!=INVALID_HANDLE){FileClose(myFile);}
  }

void OnTick()
  {
//---
   
  }

This opens up a file "myExcel.csv" in MQL5\Files\ folder which you can find by clicking Files->OpenDataFolder

Now , run this EA let it write then close it . This will create the file 

Open up your Excel and follow these steps :

Unfortunately the fastest live refresh is every 1minute.