Rejoignez notre page de fans
- Vues:
- 27515
- Note:
- Publié:
- 2014.02.10 12:45
- Mise à jour:
- 2016.11.22 07:32
-
Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance
Author:
Originally created by Russell, then modified by vedroid and now forked by lukins
Since build 600 of MT4 was released, it's no longer easy to communicate with DLLs that use ANSI format for strings because strings in MQL4 are now in UNICODE format (read more here).
This library is based on vedroid's modification of Russel's MySQL wrapper and uses techniques taken from EAX_Mysql library and from snippets posted by gchrmt4
Any contribution appreciated.
Example:
#include <mql4-mysql.mqh> string host = "localhost"; string user = "root"; string pass = "123456"; string dbName = "information_schema"; int port = 3306; int socket = 0; int client = 0; int dbConnectId = 0; bool goodConnect = false; int start () { goodConnect = init_MySQL(dbConnectId, host, user, pass, dbName, port, socket, client); if ( !goodConnect ) { return (1); // bad connect } //+------------------------------------------------------------------- //| Fetch multiple columns in multiple rows //+------------------------------------------------------------------- string query = StringConcatenate( "SELECT `TABLE_NAME`, `TABLE_ROWS`, `CREATE_TIME`, `CHECK_TIME` ", "FROM `TABLES` ", "WHERE `TABLE_SCHEMA` = \'mysql\'"); string data[][4]; // important: second dimension size must be equal to the number of columns int result = MySQL_FetchArray(dbConnectId, query, data); if ( result == 0 ) { // Print("0 rows selected"); } else if ( result == -1 ) { // Print("some error occured"); } else { // Print("Query was successful. Printing rows..."); int num_rows = ArrayRange(data, 0); int num_fields = ArrayRange(data, 1); for ( int i = 0; i < num_rows; i++) { string line = ""; for ( int j = 0; j < num_fields; j++ ) { string value = data[i][j]; line = StringConcatenate(line, value, ";"); } Print(line); } } //+------------------------------------------------------------------- //| Single row fetch //| Similar to array fetch //+------------------------------------------------------------------- string row[][4]; // important: second dimension size must be equal to the number of columns string rowQuery = StringConcatenate("SELECT `TABLE_NAME`, `TABLE_ROWS`, `CREATE_TIME`, `CHECK_TIME` ", "FROM `TABLES` ", "WHERE `TABLE_SCHEMA` = \'mysql\' ", "LIMIT 0,1"); int row_result = MySQL_FetchArray(dbConnectId, rowQuery, row); line = "One row query: "; for(int r=0; r < ArrayRange(row, 1); r++) { line = StringConcatenate(line, row[0][r], ";"); } Print(line); //+------------------------------------------------------------------- //| Sample INSERT //| It's just an example, nobody can insert into information_schema. //+------------------------------------------------------------------- /*string insertQuery = StringConcatenate( "INSERT INTO `CHARACTER_SETS` VALUES (", "sometext" , "," , "oneMoreText" , "," , "andVarialbe" , "," , "nextWillBeNumber" , "," , 2 , ")" ); if ( MySQL_Query(dbConnectId, insertQuery) ) { Print("insert good"); }*/ //+------------------------------------------------------------------- deinit_MySQL(dbConnectId); return (0); } //+------------------------------------------------------------------+
Source:
Source is distributed at Github repository. Any contribution is highly appreciated.
![Candle Direction Panels](https://c.mql5.com/i/code/indicator.png)
Shown all TF candle direction on Chart.
![mt4R for new MQL4](https://c.mql5.com/i/code/library.png)
mt4R, modified for supporting new MQL4
![DF-ProfitMonitor](https://c.mql5.com/i/code/indicator.png)
With this indicator you can follow the evolution of account profit.
![RosePipsIndicator](https://c.mql5.com/i/code/indicator.png)
This indicator will calculate pips wins and losses for any pair with a parsar and doji star trading strategy. You can see pip targets and losses and see if you can find a winning pair with this. 5MIN charts are the best on current settings.