Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Tools and utilities


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2007, 07:12 PM
Junior Member
 
Join Date: Jul 2006
Posts: 21
GP2X is on a distinguished road
Use libmysql.dll directly to read query result from MYSQL

Since mql4 doesn't support point, I didn't find any way to read the result of a select sentence. Maybe someone already created some dlls to do that which I don't know.
Here is my way, use concat_ws to put all the returned columns into one string. Map the returned row structure to a string in mql4. Then scan the string and convert to expected column values.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-13-2007, 07:13 PM
Junior Member
 
Join Date: Jul 2006
Posts: 21
GP2X is on a distinguished road
PHP Code:
//+------------------------------------------------------------------+
//|                                                  mySQLTester.mq4 |
//|                                            Copyright ?2006, GP2X |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, GP2X"
#property link      ""
#define DELIM ";"
//#include <mysql.mqh>

#import "libmysql.dll"
int mysql_init(int db);
int mysql_errno(int TMYSQL);
int mysql_real_connectint TMYSQL,string host,string user,string passwordstring DB,int port,int socket,int clientflag);
int mysql_real_query(int TMSQL,string query,int length);
void mysql_close(int TMSQL);

int mysql_store_result(int TMSQL);
string mysql_fetch_row(int result);
int mysql_num_rows(int result);
void mysql_free_result(int result);
#import

int mysql;

int mTicketmType;
string mSymbol;
double mLotsmOpenmClosemStopLossmTakeProfit;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   
string row;
   
connect();
   
string query="Select concat(';',concat_ws(';', ticket, symbol, type, lots, open, close, stoploss, takeprofit)) from trades";
   
int length=StringLen(query);
   
mysql_real_query(mysql,query,length);
   
int result mysql_store_result(mysql);
   
int numOfRows mysql_num_rows(result);
   for (
int i=0;i<numOfRows;i++) {
      
row mysql_fetch_row(result);
      
decodeTrade(row);
      
Comment("Ticket="mTicket",Symbol="mSymbol",Type="mType",Lots="mLots",Open="mOpen",Close="mClose",SL="mStopLoss",TakeProfit="mTakeProfit);
   }
   
mysql_free_result(result);
   
   return(
0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   
mysql_close(mysql);
   return(
0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   
return(0);
  }
//+------------------------------------------------------------------+

void connect() {

   
mysql mysql_init(mysql);
   if (
mysql!=0) Print("allocated");
   
string host="localhost";
   
string user="GP2X";
   
string password="forex";
   
string DB="forex";
   
int clientflag=0;
   
int port=3306;
   
string socket="";
   
int res=mysql_real_connect(mysql,host,user,password,DB,port,socket,clientflag);
   
int err=GetLastError();
   if (
res==mysql) Print("connected");
   else Print(
"error=",mysql," ",mysql_errno(mysql)," ");

}

void decodeTrade(string trade) {
   
int begin StringFind(tradeDELIM)+1;
   
int end StringFind(tradeDELIMbegin);
   
mTicket StrToInteger(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mSymbol StringSubstr(tradebeginend-begin);
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mType StrToInteger(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mLots StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mOpen StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mClose StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mStopLoss StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringLen(trade);
   
mTakeProfit StrToDouble(StringSubstr(tradebeginend-begin));

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-13-2007, 07:44 PM
Senior Member
 
Join Date: Mar 2006
Posts: 893
barnix is on a distinguished road
mysql Delphi MT4 example from a russian forum
http://treide.ru/modules/newbb_plus/...rder=0&start=0
Attached Files
File Type: zip mysql.zip (30.9 KB, 97 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-12-2007, 03:56 PM
Junior Member
 
Join Date: Apr 2006
Posts: 1
ttauzo is on a distinguished road
connect to oracle XE from Metatrader

Has anyone tried it? I can connect to MySQL but have no idea how to do it with Oracle?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-23-2008, 07:22 PM
Member
 
Join Date: Jul 2007
Posts: 98
muyuan11 is on a distinguished road
Thumbs up it work fine

it work fine
Quote:
Originally Posted by GP2X View Post
PHP Code:
//+------------------------------------------------------------------+
//|                                                  mySQLTester.mq4 |
//|                                            Copyright ?2006, GP2X |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, GP2X"
#property link      ""
#define DELIM ";"
//#include <mysql.mqh>

#import "libmysql.dll"
int mysql_init(int db);
int mysql_errno(int TMYSQL);
int mysql_real_connectint TMYSQL,string host,string user,string passwordstring DB,int port,int socket,int clientflag);
int mysql_real_query(int TMSQL,string query,int length);
void mysql_close(int TMSQL);

int mysql_store_result(int TMSQL);
string mysql_fetch_row(int result);
int mysql_num_rows(int result);
void mysql_free_result(int result);
#import

int mysql;

int mTicketmType;
string mSymbol;
double mLotsmOpenmClosemStopLossmTakeProfit;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   
string row;
   
connect();
   
string query="Select concat(';',concat_ws(';', ticket, symbol, type, lots, open, close, stoploss, takeprofit)) from trades";
   
int length=StringLen(query);
   
mysql_real_query(mysql,query,length);
   
int result mysql_store_result(mysql);
   
int numOfRows mysql_num_rows(result);
   for (
int i=0;i<numOfRows;i++) {
      
row mysql_fetch_row(result);
      
decodeTrade(row);
      
Comment("Ticket="mTicket",Symbol="mSymbol",Type="mType",Lots="mLots",Open="mOpen",Close="mClose",SL="mStopLoss",TakeProfit="mTakeProfit);
   }
   
mysql_free_result(result);
   
   return(
0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   
mysql_close(mysql);
   return(
0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   
return(0);
  }
//+------------------------------------------------------------------+

void connect() {

   
mysql mysql_init(mysql);
   if (
mysql!=0) Print("allocated");
   
string host="localhost";
   
string user="GP2X";
   
string password="forex";
   
string DB="forex";
   
int clientflag=0;
   
int port=3306;
   
string socket="";
   
int res=mysql_real_connect(mysql,host,user,password,DB,port,socket,clientflag);
   
int err=GetLastError();
   if (
res==mysql) Print("connected");
   else Print(
"error=",mysql," ",mysql_errno(mysql)," ");

}

void decodeTrade(string trade) {
   
int begin StringFind(tradeDELIM)+1;
   
int end StringFind(tradeDELIMbegin);
   
mTicket StrToInteger(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mSymbol StringSubstr(tradebeginend-begin);
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mType StrToInteger(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mLots StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mOpen StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mClose StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringFind(tradeDELIMbegin);
   
mStopLoss StrToDouble(StringSubstr(tradebeginend-begin));
   
begin end+1;
   
end StringLen(trade);
   
mTakeProfit StrToDouble(StringSubstr(tradebeginend-begin));

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
mysql.mqh, mql4 mysql, libmysql.dll, metatrader mysql

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT Query junglelion Indicators - Metatrader 4 0 06-03-2007 10:16 PM
Different backtesting result of same EA. takechance Metatrader 4 2 10-10-2006 05:00 AM
MT4 to mySQL witchazel Questions 2 09-16-2006 01:36 AM
Use another Indicator Result NoName Questions 0 04-09-2006 03:35 AM


All times are GMT. The time now is 05:33 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.