Discussion of article "How to Access the MySQL Database from MQL5 (MQL4)" - page 2

To add comments, please log in or register
Eugeniy Lugovoy
1928
Eugeniy Lugovoy  
carmine.marrone:

Hello elugovoy

 Awesome article and great libraries.

 I'm trying to use your examples under MT5 but I'm getting this error: 

2014.12.15 15:44:16.387 MySQL-001 'C:\Users\....\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\libraries\MQLMySQL.dll' is not 64-bit version

Are you  running MT5 under 32-bit env?

 Could you pleas help me with it? 

 Thanks very much!

 Carmine Marrone. 

Hello Carmine

The above in discussion I have attached project for x64, take a look and/or download from this post.

Hope this helps.

Regards,

Eugene 

Ingvar Engelbrecht
4408
Ingvar Engelbrecht  

Hi.

Like the concept. Should be a great help

But I run into some problem. I am using 64 bit nd I have downloaded them and started out on a test script to see how it works.

but crashes in MySQLGetFieldAsxxxxx

2015.01.09 21:32:09.535    testsql (AUDNZD,H1)                  000000013F81347A 488BF2            mov        rsi, rdx
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)                  000000013F813476 4883EC20          sub        rsp, 0x20
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)                  000000013F813475 57                push       rdi
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)                  000000013F813470 4889742418        mov        [rsp+0x18], rsi
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)    Access violation at 0x000000013F8134B3 read to 0x0000000000000001
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)    +++++++++++++0
2015.01.09 21:32:09.535    testsql (AUDNZD,H1)    2 row(s) selected.
2015.01.09 21:32:09.425    testsql (AUDNZD,H1)    Connected
2015.01.09 21:31:18.135    testsql (AUDNZD,H1)    x  0  y


Sorce:

#include <FXCM\PairsInfo.mqh>
#include <FXCM\MQLMySQL.mqh>

//--- input parameters
input string   MySQLURL="yyyyyyyyyyyyyy";
input string   MySQLDB = "forex";
input string   MySQLParms = "tradeparms";
input string   MySQLUser="Ingvar";
input string   MySQLPW="xxxxxxxxxxxx";
input int      MySQLPort=3306;
input string   GroupID= "Groupxxx";

PairsInfo prms;

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
  string SQLString = "";
  string Q;
  string C = ",";
  StringSetCharacter(Q,0,34);
  
  string query;
  int Cursor;
  int DB;
  int rows;
  
  DB = MySqlConnect(MySQLURL, MySQLUser, MySQLPW, MySQLDB, MySQLPort, "0", 0);
  if (DB == -1) 
    {
      Print ("Connection failed! Error: "+MySqlErrorDescription); 
      return;
    }

    Print ("Connected");
    
  //  query = "Select * From tradeparms";
    
  //  query = "Select * FROM tradeparms WHERE TradeType = 2";
    
    query = "SELECT Pair, TradeType, SetupID FROM tradeparms WHERE TradeType = 2 AND Pair = 'USDJPY'";
     
     
   Cursor = MySqlCursorOpen(DB,query);
   if(Cursor <  0)
    {
      Print("Cursor error");
      return;
    }


   string pair= "x";
   int tradetype = 0;
   string setupid = "y";
   
   rows = MySqlCursorRows(Cursor);
   Print (rows, " row(s) selected.");
   
   for(int i=0;i<rows;i++)
    {
     if (MySqlCursorFetchRow(Cursor))  
       {
        Print("+++++++++++++" + i);
        pair = MySqlGetFieldAsString(Cursor, 0);                    << crashes here.   
   //     tradetype = MySqlGetFieldAsInt(Cursor,1);
   //      setupid = MySqlGetFieldAsString(Cursor,2);
       }
     }  
      
   Print(pair + "  " + DoubleToString(tradetype,0) + "  " + setupid);
   
   MySqlCursorClose(Cursor);
 
  
 } 
Ingvar Engelbrecht
4408
Ingvar Engelbrecht  

I dug out my old laptop with win32 and installed the 32 bit version on it and compiled the same source with 32 bits library and includes.

Works fine. Problem is with 64 bit version

Eugeniy Lugovoy
1928
Eugeniy Lugovoy  
ingvar_e:

I dug out my old laptop with win32 and installed the 32 bit version on it and compiled the same source with 32 bits library and includes.

Works fine. Problem is with 64 bit version

Ok, will check this.

What's the version of terminal? MT4/MT5? and build number

Ingvar Engelbrecht
4408
Ingvar Engelbrecht  
elugovoy:

Ok, will check this.

What's the version of terminal? MT4/MT5? and build number

  Terminal MT5  Build 1035.  Running on W7 64   crash

  Terminal MT5  Build 1035   Running on  XP 32   OK

  Appreciate it. Working on  a multi curreny, muli method (sort of) EA that currently uses an input file. For flexibility in testing different input files I am converting to MySQL

Eugeniy Lugovoy
1928
Eugeniy Lugovoy  
ingvar_e:

  Terminal MT5  Build 1035.  Running on W7 64   crash

  Terminal MT5  Build 1035   Running on  XP 32   OK

  Appreciate it. Working on  a multi curreny, muli method (sort of) EA that currently uses an input file. For flexibility in testing different input files I am converting to MySQL

I've tested it on x64 OS, MT5 build 1035. You are absolutely right.

I've made some checks and found that the data coming to DLL works fine. The problem is in receiving STRING datatype from DLL functions.

Also, I have tested my own scripts has been compiled with previous build of MT5 x64 - works fine.

But after recompiling with build 1035, the same script with the same DLL brings such errors.

Finally, I assume that the problem is not in DLL or MQLMySQL project, but in MT5 x64 compiler. I've opened case in service desk for this issue.

Thanks,

Eugene 

Eugeniy Lugovoy
1928
Eugeniy Lugovoy  
ingvar_e:

  Terminal MT5  Build 1035.  Running on W7 64   crash

  Terminal MT5  Build 1035   Running on  XP 32   OK

  Appreciate it. Working on  a multi curreny, muli method (sort of) EA that currently uses an input file. For flexibility in testing different input files I am converting to MySQL

Just for testing, you can use my scripts included to distribution package.

Change database credentials in  INI file, then run scripts. 

Try to recompile them and run again.

You will see that on 1st run they works fine, but after recomiling they brings same errors with yours.

Problem is in MT5 x64 b1035  terminal/compiler 

Ingvar Engelbrecht
4408
Ingvar Engelbrecht  
elugovoy:

Just for testing, you can use my scripts included to distribution package.

Change database credentials in  INI file, then run scripts. 

Try to recompile them and run again.

You will see that on 1st run they works fine, but after recomiling they brings same errors with yours.

Problem is in MT5 x64 b1035  terminal/compiler 

>Problem is in MT5 x64 b1035  

So we are stuck??

My old 32bit laptop gave up today. Completely dead.

I wonder if I can install a 32 bits windows on a 64 bit machine and if that really helps. Or install a MT5/MQL5 32 bit on a Windows 7 64 bit machine

Later:

Found this  Trying it.

  • To install the 32 bit version in a 64 bit operating system, you should start the installer with the /32 key. For example c:\>mt5setup.exe /32.
  • http://www.metatrader5.com/en/terminal/help/startworking/installation
Ingvar Engelbrecht
4408
Ingvar Engelbrecht  
ingvar_e:

>Problem is in MT5 x64 b1035  

So we are stuck??

My old 32bit laptop gave up today. Completely dead.

I wonder if I can install a 32 bits windows on a 64 bit machine and if that really helps. Or install a MT5/MQL5 32 bit on a Windows 7 64 bit machine

Later:

Found this  Trying it.

  • To install the 32 bit version in a 64 bit operating system, you should start the installer with the /32 key. For example c:\>mt5setup.exe /32.
  • http://www.metatrader5.com/en/terminal/help/startworking/installation

   Install of 32-bit M5 worked fine and compiling worked fine but I could not get the tickvalue by

  SymbolInfoDouble(pair,SYMBOL_TRADE_TICK_VALUE)

  returns 0;

  Maybe its not a good idea to run a 32 bit MT5 on a windows 64 bit machine. Have other indications too of malfunction. Next try is to install a windows 32 on my 64 bit computer.

 Always these long detours taken you a long way off yourmain course :-(

Seems like I have to give up on this tool and get down to basics with MySQL. To much hassle installing a new windows XP and have no W7 key


 

Eugeniy Lugovoy
1928
Eugeniy Lugovoy  
ingvar_e:

   Install of 32-bit M5 worked fine and compiling worked fine but I could not get the tickvalue by

  SymbolInfoDouble(pair,SYMBOL_TRADE_TICK_VALUE)

  returns 0;

  Maybe its not a good idea to run a 32 bit MT5 on a windows 64 bit machine. Have other indications too of malfunction. Next try is to install a windows 32 on my 64 bit computer.

 Always these long detours taken you a long way off yourmain course :-(

Seems like I have to give up on this tool and get down to basics with MySQL. To much hassle installing a new windows XP and have no W7 key

I'm working on this issue with service desk, hope to hear from any good news soon.

Regarding TICK_VALUE, I've had the same troubles too even in MT4. Here is workaround I'm using:

tick_value = 0;
while (tick_value<=0) { tick_value = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);}

 or

tick_value = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);
while (!MathIsValidNumber(tick_value))
      {
       Sleep(50);
       tick_value = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE); 
      }
To add comments, please log in or register