Download MetaTrader 5

Here is how to connect MT4 to Excel - trade from excel, live indicators in excel etc

To add comments, please log in or register
soniabvc
51
soniabvc  
Its all explained here www.<edited>.com
Taskin Osman
837
Taskin Osman  

also check



// EXCELLINK
// http://www.fx1.net/excellink.php  demonstration
//
// download and copy .dll file into experts/libraries directory
//
// This simple demonstration script in mql4
// Starts excel and generates a 5 x 5 random number generated matrix
// then adds them with help of sum() excel function
// It also demonstrates cell formatting capabilities of addon
//
#import "excellink.dll"
   int ExcelStart(string,int);
   string ExcelVersion();
   int ExcelPutString(int,int,int,string);
   int ExcelPutValue(int,int,int,double);
   int ExcelFormatCellColor(int,int,int,int,int);
   int ExcelFormatCellFontSize(int,int,int,int);
   int ExcelFormatCellFont(int,int,int,int);
   double ExcelGetValue(int,int,int);
   string ExcelGetString(int,int,int);
   int ExcelSaveFile(string);
   int ExcelSheetRename(int, string);
   int ExcelPutCalc(int,int,int,string);
   string ExcelCell(int,int);
   int ExcelUnixTime();
#import


int start()
  {
   // we open excel
   int row,col;
   string filename = "c:\temp\demo1.xls";
   int e = ExcelStart(filename,1);
   if ( e >= 0 )
      {
      // success

      // String operations and formatting
      ExcelPutString(1,1,1,"Excel Link Demonstration");
      ExcelPutString(1,2,1,"You are running ExcelLink Version "+ExcelVersion());
      ExcelFormatCellFontSize(1,1,1,15);
      ExcelFormatCellFont(1,1,1,1+2);
      ExcelFormatCellFontSize(1,2,1,12);
      ExcelFormatCellColor(1,1,1,White,Red);

      // Lets generate random numbers
      row = 3; col = 3; MathSrand(TimeLocal());
      ExcelPutString(1,2,8,"Sum()");
      for (row=2;row<8;row++)
         {
         for (col=3;col<8;col++)
            {
               if (row==2)
               {
                  ExcelPutString(1,row,col,"Col "+DoubleToStr(col-2,0));
                  ExcelFormatCellFont(1,row,col,7);
               }
               else
               {
                  ExcelPutValue(1,row,col,MathRand());
               }
            }
            // we use =sum() function to add cells
            if (row>2)
               {
                  ExcelPutCalc(1,row,col
                  ,"=Sum("+ExcelCell(row,col-5)+":"+ExcelCell(row,col-1)+")");
               }
         }

      }
         ExcelSaveFile(filename);
   return(0);
  }
sonfx
5
sonfx  

I visited thesite www.<edited>.com. My question is if I can use VBA with that application?

im
55
im  
From what I see the site only gives a free 10 day trial of <edited> trader. But maybe you are looking a t something else. The <edited> trading simulator is pretty cool though. I guess between the above code and MT4 all of that can be done by some one that can put things together. Ill look around some more for a simple excel sheet with basic instruction other wise I will look in to the above code 
im
55
im  

This does attach the two, 

But it seems to be giving random numbers.  Are the random numbers generated from MT4 or are they generated in excel itself?

 

Is there an example that has 2 way communication between excel and MT4 like doing a price query in excel and having MT4  compute it and the answer to the query is then imputed in to excel?

Since that has clear 2 way communication it is something that one could build on.  

Pavel Soukup
560
Pavel Soukup  

Hi,

do you work function ExcelGetValue( ) right?

I download version 3.6 of excellink.dll and it return only zero value.

Can you send me, please, excellink.dll your version? Thank you very mutch.

Endy

Pavel Soukup
560
Pavel Soukup  

Ok ;-) Maybe I understand where was error. My problem excel vs. MT

When I write to excel A1 any number, function ExcelGetValue() return to MT ok, I am using syntax: double num=ExcelGetValue(1,1,1)

BUT

When I write to excel A1 "=C3+D3" (any formula),  function ExcelGetValue() return to MT always zero value

                                                                          function ExcelGetString() return to MT:  =R[2]C[2]+R[2]C[3] 

 

 My question is: How get value (number/content cell A1 ) to MT?

To add comments, please log in or register