거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

MySQL for new MQL4 (tested in build 600) - MetaTrader 4용 라이브러리

조회수:
27361
평가:
(26)
게시됨:
2014.02.10 12:45
업데이트됨:
2016.11.22 07:32
\MQL4\Include\
MQL4.zip (942.18 KB)
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

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.