Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

MySQL wrapper - library for MetaTrader 4

Views:
22157
Rating:
(10)
Published:
2008.12.15 07:13
Updated:
2016.11.22 07:32
\MQL4\Include\
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Author:

Russell

There are a few solutions around for reading and writing to MySQL databases. Writing to MySQL is in general not a big problem in MT4. But the reading part is kinda hard. MT4 can't handle C++ structures very well, only the native types such as int, double and string are supported. Other solutions use a SELECT statement CONCATing the wanted fields. I found this solution unstable and therefor a high error risk. The wrapper translates two MySQL structures to the types MT4 can handle. All orignal functions of libmysql are exported in the wrapper as well. Full sourcecode available in zip-file.

Example:

#include <mysql_v2.0.4.mqh>

int init(){
   Print(MT4_mysql_wrapper_version());
   MySQL_Init();
   getDB();
   return(0);
}

int deinit(){
   MySQL_DeInit();
   return(0);
}

int start(){
   return(0);
}

void getDB(){ 
   //--------------v    set this to the number of fields you're selecting
   string lsData[][2];
   string lsQuery = "SELECT tableid,some_value FROM `mytable` INNER JOIN .... WHERE ... ORDER BY ...";
   MySQL_FetchArray(lsQuery, lsData); 
   for (int i = 0; i < ArrayRange(lsData,0); i++){
      for (int j = 0; j < ArrayRange(lsData,1); j++){
         Print(i+","+j+": "+lsData[i][j]);
      }
   }
}

Credits:

https://www.mql5.com/en/users/gc1 for pointing out some bugs


Install:

mysql_v2.0.2.mqh - goes to your include directory

mysql_wrapper_v1.0.2.zip

- open the zip

- extract mysql_wrapper_v1.0.2.zip\mysql_wrapper\Debug\mysql_wrapper.dll to C:\Windows\system32\


Discussion:

https://www.mql5.com/en/forum/111508


Update:

mysql_v2.0.4.mqh - has some extra error checks

mysql_wrapper_v1.0.3.zip - repack VS2008



Exoticwavein Exoticwavein

The indicator writes the history to the CSV file.

Internal Bar Strength (IBS) Internal Bar Strength (IBS)

It is calculated as the moving average of the values of the internal bars strength.

OrdersSuite Revision 2 OrdersSuite Revision 2

Functions for processing the orders of Spot currency pairs, Spot Gold and Spot Silver with error handling. OrderProcess() strengthened. New functions Lots, OrderCloseByRetracement, OrderModifyTS and OrderSendI added. Revision 2 has been used to run expert

Candle Patterns Candle Patterns

Visual and Audio alerts when reversal or continuation candle patterns occur.