Accidently I ran into MQL5 and was forced to pull a MySQL library together. As for any library I hope the examples show how the library can be used. As for any library actually the most important things are examples how to use it ;)
Examples:
Reading Data
#include <EAX\EAX_Mysql.mqh> EAX_Mysql *db = new EAX_Mysql(); db.connect("myhost.mydomain.com", "myusername", "mypassword", "mydatabase", "mytable"); int iResults = db.read_rows("SELECT password, COUNT(*) as Hits FROM users GROUP BY password"); for (int i=0; i < iResults; i++) { string password = (string) db.get("password",i); int hits = (int) db.get("Hits", i); }
Feeding Data
#include <EAX\EAX_Mysql.mqh> // global EAX_Mysql *db = new EAX_Mysql(); void OnInit() { db.connect("myhost.mydomain.com", "myusername", "mypassword", "metatrader", "Ticks"; } void OnTick() { MqlTick tick; SymbolInfoTick(_Symbol,tick); // Add a new dataset for table Ticks db.AddNew("Ticks"); // fill it with values.. db.set("symbol", _Symbol); // You can send digits to digit DB fields if MySQL can convert db.set("ask", tick.ask); db.set("bid", tick.bid); db.set("last", tick.last); db.set("time", TimeToString(tick.time,TIME_DATE) + " " + TimeToString(tick.time,TIME_SECONDS)); db.set("volume", tick.volume); db.write(); } void OnDeinit() { // clean up memory delete db; }
Interacting with Data
EAX_Mysql *db = new EAX_Mysql(); db.connect("myhost.mydomain.com", "myusername", "mypassword", "metatrader", "mytable") // Select Table AgentsOnline (required to identify the correct Primary Key) db.select("AgentsOnline"); // Read Dataset with Primary Key 5 db.read("5"); // modify any column, db.set("lastupdate", (string) TimeLocal()); // write it back db.write();
Installing:
Issues:
Credits:
ExtObjects
Dedicated functions to read and write object properties.
Momentum Color Fill
The Momentum Technical Indicator measures the change of price of a financial instrument over a given time span.
DaysOfWeekCheck
The function is used to determine weekends on a server. It will be especially useful to those who use OnTimer() function in their Expert Advisors for events handling.
OpenBuyPosition
The script is developed for buying with fixed Stop Loss and Take Profit values in points from the current price.