Discussion of article "How to Access the MySQL Database from MQL5 (MQL4)" - page 8

To add comments, please log in or register
dragossh
3
dragossh  
MetaQuotes Software Corp.:

New article How to Access the MySQL Database from MQL5 (MQL4) has been published:

Author: Eugeniy Lugovoy

Hi Eugeniy Lugovoy,

Firstly, thank you for taking the time to make this project.

I've been looking for weeks on how to import/update all the open/closed trades from a trading account into a MySQL table, if possible realtime.  is there a way to do this using your library?

Many thanks in advance.

Dragos

Amy Liu
937
Amy Liu  
Thank the author, I modified this project locally, so that I can use non-English words store in MySQL DB code page UTF8.
Eugeniy Lugovoy
1966
Eugeniy Lugovoy  
Amy Liu:
Thank the author, I modified this project locally, so that I can use non-English words store in MySQL DB code page UTF8.

Hi Amy. It's great, I had no time to do it by myself. So, if that's alright by you, can you share sources with community?

Eugeniy Lugovoy
1966
Eugeniy Lugovoy  

Hello to everyone!

Unfortunately, I have no time to support this project and to spend time in community, so All My Dears forgive me unanswered questions and my silence.

But I see some experienced people here which can help to others and it's really great.

Thank you all for using my library, extending its functionality and getting your own experience.

Good luck to all with your projects!


Kindest regards,

Eugene

Eugeniy Lugovoy
1966
Eugeniy Lugovoy  
dragossh:

Hi Eugeniy Lugovoy,

Firstly, thank you for taking the time to make this project.

I've been looking for weeks on how to import/update all the open/closed trades from a trading account into a MySQL table, if possible realtime.  is there a way to do this using your library?

Many thanks in advance.

Dragos

Hi Dragos!

Sure, you can build EA using this library to insert data into your Mysql database and keep them up to date (close to realtime update).

Pay attention, that closed orders in MT4/5 available programmatically only when they listed in History tab. So, if you set the filter in History 3 recent days - you can access only trades processed in that period.

It's not depended on this library, it's just MQL-MT4 infrastructure.

Regards,

Eugene

George Oakes
5
George Oakes  

Eugene,

Awesome work again as this was very simple to get working.

Curious, have you or anyone else here tried to get this working on the Strategy Tester? I've evolved the script onto an indie in the live environment and all is OK, but no luck integrating in a backtesting envionment.


br George

Amy Liu
937
Amy Liu  
Eugeniy Lugovoy:

Hi Amy. It's great, I had no time to do it by myself. So, if that's alright by you, can you share sources with community?

Hi Eugeniy,

Sorry for late response. Here is what i did with your code. I just modified one function cMySqlGetRowField to use MultiByteToWideChar. The original code is commented for compare.

// return string representation of field's value
// should be called after MySqlCursorFetchRow()
// pCursorID - CURSOR IDENTIFIER
// pField    - number of field from SELECT list (started from 0) - 0,1,2 e.t.c.
MT4_EXPFUNC wchar_t* __stdcall cMySqlGetRowField(int pCursorID, unsigned int pField)
{
        SCOPE_LOCK_MUTEX(g_mutex.get());
        ClearCursorErrors(pCursorID);
        if ((pCursorID >= 0) && (pCursorID < MAX_CURSORS) && (Cursors[pCursorID].Id!=-1))
        {
                if ((pField >= 0) && (pField < mysql_num_fields(Cursors[pCursorID].RecordSet)))
                {
                        // 预算-缓冲区中宽字节的长度
                        int unicodeLen = MultiByteToWideChar(CP_UTF8, 0, Cursors[pCursorID].CurrentRow[pField], -1, nullptr, 0);
                        if (unicodeLen<=1024)
                        {
                                // 开始向缓冲区转换字节
                                MultiByteToWideChar(CP_UTF8, 0, Cursors[pCursorID].CurrentRow[pField], -1, Cursors[pCursorID].Value, unicodeLen);
                                return(Cursors[pCursorID].Value);
                        }
                        //sprintf_s(Cursors[pCursorID].Value, "%s", Cursors[pCursorID].CurrentRow[pField]);
                        //swprintf(Cursors[pCursorID].Value, 1024, L"%S", Cursors[pCursorID].CurrentRow[pField]);
                        //return (Cursors[pCursorID].Value);
                }
                else
                {
                        Cursors[pCursorID].CursorErrorNumber = -4;
            swprintf(Cursors[pCursorID].CursorErrorDescription, 32, L"Wrong number of field.\x00");
                }
        }
        else
        {
                CursorErrorNumber = -5;
                swprintf(CursorErrorDescription, 32, L"Wrong CURSOR identifier.\x00");
        }
        return (WideNull);
}
Ma Yuliang
296
Ma Yuliang  
Amy Liu:

Hi Eugeniy,

Sorry for late response. Here is what i did with your code. I just modified one function cMySqlGetRowField to use MultiByteToWideChar. The original code is commented for compare.

Thanks your guys are great. I tried your code .Don't forget includ widechar head, or it'll not work.

#include <wchar.h>



 

To add comments, please log in or register