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.
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.
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(trade, DELIM)+1;
int end = StringFind(trade, DELIM, begin);
mTicket = StrToInteger(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mSymbol = StringSubstr(trade, begin, end-begin);
begin = end+1;
end = StringFind(trade, DELIM, begin);
mType = StrToInteger(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mLots = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mOpen = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mClose = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mStopLoss = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringLen(trade);
mTakeProfit = StrToDouble(StringSubstr(trade, begin, end-begin));
}
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(trade, DELIM)+1;
int end = StringFind(trade, DELIM, begin);
mTicket = StrToInteger(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mSymbol = StringSubstr(trade, begin, end-begin);
begin = end+1;
end = StringFind(trade, DELIM, begin);
mType = StrToInteger(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mLots = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mOpen = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mClose = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringFind(trade, DELIM, begin);
mStopLoss = StrToDouble(StringSubstr(trade, begin, end-begin));
begin = end+1;
end = StringLen(trade);
mTakeProfit = StrToDouble(StringSubstr(trade, begin, end-begin));
}
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 ?