Schau, wie man Roboter kostenlos herunterladen kann
Find us on Facebook!
Join our fan page
Interessantes Skript?
Veröffentliche einen Link auf das Skript, damit die anderen ihn auch nutzen können
Hat Ihnen das Skript gefallen?
Bewerten Sie es im Terminal MetaTrader 5
Bibliotheken

MySQL for new MQL4 (tested in build 600) - Bibliothek für den MetaTrader 4

Ansichten:
26967
Rating:
(26)
Veröffentlicht:
2014.02.10 12:45
Aktualisiert:
2016.11.22 07:32
\MQL4\Include\
MQL4.zip (942.18 KB)
Benötigen Sie einen Roboter oder Indikator, der auf diesem Code basiert? Bestellen Sie ihn im Freelance-Bereich Zum 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 Candle Direction Panels

Shown all TF candle direction on Chart.

mt4R for new MQL4 mt4R for new MQL4

mt4R, modified for supporting new MQL4

DF-ProfitMonitor DF-ProfitMonitor

With this indicator you can follow the evolution of account profit.

RosePipsIndicator RosePipsIndicator

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.