MT5访问MYSQL数据库完整源码,MQL5读写MYSQL源码,MT5下MQLMySQL.dll源码
在 MT5 通过 MQL5 与 MYSQL 之间交互实现:
MQL5 和 MySQL 交互原理:
MQL5通过调用 接口库 MQLMySQL.mqh. 使用 #include 语句将它加到项目工程里。它包含的指令用于导入 MQLMySQL64.dll 动态库的函数,以及调用它们和处理函数。而MQLMySQL调用的是MYSQL的 libmysql.dll 64位动态链接库。 实现MT5 (MQL5) 访问 MySQL 数据库(支持中文读取写入)的目的。
提示:本人修改了VC++ 写的 MQLMySQL 源码。让其支持中文。采用unicode编译。调用中文范例MQL源码与MQLMySQL dll完整源码在压缩包里有。
补充:前面有兄弟问,MT5调用MYSQL能做什么?有什么用?
1. 做远程网络验证。购买一个便宜的阿里云RDS MYSQL,MQL里远程访问指读的数据库,实现指标、EA等等用户身份验证。虽然有点LOW,但也是解决问题的一种方法。
2. 做远程跟单系统或者定单上传系统。 通过读取MT5内定单信息上传或存入数据库,实现这些功能。跟上方法一样。
3.实时的保存MT5行情数据到数据库,另做它用。
4.其它用处。。。。
MQL5源码与dll源码.rar 策汇在线.url 必须读我.txt MQL4/ MQL4/Include/ MQL4/Include/MQLMySQL.mqh MQL4/Libraries/ MQL4/Libraries/libmysql.dll MQL4/Libraries/MQLMySQL.dll MQL4/Scripts/ MQL4/Scripts/MyConnection.ini MQL4/Scripts/MySQL 1.连接.mq4 MQL4/Scripts/MYSQL 2.创建表.mq4 MQL4/Scripts/MYSQL 3.插入数据.mq4 MQL4/Scripts/MYSQL 4.读取数据.mq4MQL4/Scripts/MySQL 1.连接.mq4代码片段:
#property copyright "Copyright 2019 策汇在线" #property link "http://www.fxchs.com" #property version "1.00" #property strict #include string INI; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { string Host, User, Password, Database, Socket; // database credentials int Port,ClientFlag; int DB1,DB2,DB3; // database identifiers Print (MySqlVersion()); string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); string strDbConfig = terminal_data_path + "\\MQL4\\Scripts\\MyConnection.ini"; Print("数据库配置文件路径:",strDbConfig); // reading database credentials from INI file Host = ReadIni(strDbConfig, "MYSQL", "Host"); User = ReadIni(strDbConfig, "MYSQL", "User"); Password = ReadIni(strDbConfig, "MYSQL", "Password"); Database = ReadIni(strDbConfig, "MYSQL", "Database"); Port = StrToInteger(ReadIni(strDbConfig, "MYSQL", "Port")); Socket = ReadIni(strDbConfig, "MYSQL", "Socket"); ClientFlag = StrToInteger(ReadIni(strDbConfig, "MYSQL", "ClientFlag")); Print ("Host: ",Host, ", User: ", User, ", Database: ",Database); // open database connection Print ("Connecting..."); DB1 = MySqlConnect(Host, User, Password, Database, Port, Socket, ClientFlag); if (DB1 == -1) { Print ("Connection failed! Error: "+MySqlErrorDescription); } else { Print ("Connected! DBID#",DB1);} DB2 = MySqlConnect(Host, User, Password, Database, Port, Socket, ClientFlag); if (DB2 == -1) { Print ("Connection failed! Error: "+MySqlErrorDescription); } else { Print ("Connected! DBID#",DB2);} DB3 = MySqlConnect(Host, User, Password, Database, Port, Socket, ClientFlag); if (DB3 == -1) { Print ("Connection failed! Error: "+MySqlErrorDescription); } else { Print ("Connected! DBID#",DB3);} MySqlDisconnect(DB3); MySqlDisconnect(DB2); MySqlDisconnect(DB1); Print ("All connections closed. Script done!"); } //+------------------------------------------------------------------+