Download MetaTrader 5

Experts: TicksInMySQL

To add comments, please log in or register
Register as a seller and start making profit!
MetaQuotes Software Corp.
Moderator
181061
MetaQuotes Software Corp. 2006.07.20 10:16 

TicksInMySQL:

TicksInMySQL Expert Advisor.

Author: Collector

MQL4 Comments
16319
MQL4 Comments 2007.01.19 23:40  
i would like to know how it works

and can we do it for MS Access??


that 's good work at all
Mehmet Bastem
240
Mehmet Bastem 2008.09.13 04:46  

WRITE CODE

  string query = "";

   int length = 0;
   query = StringConcatenate("insert into ticks(margin,freemargin,date,ask,bid,symbol,equity) values(",
                             AccountMargin(), ",", AccountFreeMargin(), ",\"",
                             TimeToStr(CurTime(), TIME_DATE|TIME_SECONDS), "\",",
                             NormalizeDouble(Ask, 4), ",", NormalizeDouble(Bid, 4),
                             ",\"", Symbol(), "\",", AccountEquity(), ");");
   length = StringLen(query);
   mysql_real_query(mysql, query, length);
   int myerr = mysql_errno(mysql);
   if(myerr > 0)
       Print("error=",myerr);

 

HOW DO READ CODE ?

SAMPLE Select equity from tick ?

Wouter Luberti
9
Wouter Luberti 2014.11.24 14:22  

This puts data into the database. Before you can use this you need a database & table to save the data in.

 I *think* this should be the MySQL table structure:

 CREATE TABLE IF NOT EXISTS yourtablename (

id int(11) NOT NULL AUTO_INCREMENT,

  margin float NOT NULL,

  freemargin float NOT NULL,

  `date` datetime NOT NULL,

  ask float NOT NULL,

  bid float NOT NULL,

  symbol varchar(25) NOT NULL,

  equity float NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

After the data has been entered into the table by any SELECT query. For instance to select only the last 5 entries (in MySQL):

SELECT * FROM yourtablename ORDER BY id DESC LIMIT 5;

I will post the actual script/mql part as soon as I have played around with it for a bit :)

To add comments, please log in or register