Forex



Go Back   Forex Trading > Downloads > Tools and utilities
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web 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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 01-13-2007, 07:44 PM
Senior Member
 
Join Date: Mar 2006
Posts: 1,069
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, 222 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web 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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 11-23-2008, 07:22 PM
Senior Member
 
Join Date: Jul 2007
Posts: 123
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 11-09-2009, 08:05 AM
Senior Member
 
Join Date: Oct 2007
Posts: 117
mudar is on a distinguished road
"libmysql.dll" does not work

Dear All, I am using "libmysql.dll" in my EA, on testing mode, this seems to work fine, and in live mode Metatrader crash.
Anyone have any idea how to solve this ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
mysql.mqh, mql4 mysql, libmysql.dll, metatrader mysql, use libmysql.dll, mt4 mysql, how to use libmysql.dll, mysql_fetch_row mql4, mysql


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 12:38 PM.



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