Errors, bugs, questions - page 3079

 
The screenshot is not loading in the marketplace. Tried it from two browsers.
 
Dmitry Fedoseev #:
Market doesn't load a screenshot. Tried from two browsers.

Me too...

 

Good afternoon, what could be the problem? I use dll to write to SQL Server (example from article https://www.mql5.com/ru/articles/2895 ).

If I use up to 5 threads, data is written correctly. If I use more threads, there will be an error "Unhandled exception 0xE0434352".

Интеграция эксперта на MQL и базы данных (SQL Server, .NET и C#)
Интеграция эксперта на MQL и базы данных (SQL Server, .NET и C#)
  • www.mql5.com
Статья описывает, как добавить в экспертов на MQL5 возможность работы с сервером баз данных Microsoft SQL Server. Используется импорт функций из DLL. Для создания DLL применяется платформа Microsoft .NET и язык C#. Используемые в статье методы с незначительными изменениями подходят и для экспертов, написанных на MQL4.
Files:
SQL.mqh  19 kb
OHLC_1.mq5  5 kb
 
SEM #:

Good afternoon, what could be the problem? I use dll to write to SQL Server (example from article https://www.mql5.com/ru/articles/2895 ).

If I use up to 5 threads, data is written correctly. If I use more threads error "Unhandled exception 0xE0434352" appears at once.

In all functions of interface DLL we should use try catch, catch "unhandled exception" and write it into log...

It's a good idea to catch all exceptions and try all calls to the pluses. Even in MQL documentation it's clearly written - DLL's shouldn't throw exceptions, not C++.

in particular in the article conn.Close and new SqlConnection don't fall under "exception catching" and can potentially throw exceptions

 
Dmitry Fedoseev #:
The screenshot is not loading in the Marketplace. I tried it with two browsers.
Yury Emeliyanov #:

Me too...

Have you tried a simple drag and drop of the picture?

Forum on trading, automated trading systems and strategy testing

Market and Math

Alexey Viktorov, 2021.08.19 21:01

Try to insert a picture by simple dragging and dropping it on the text.

I have now tried to make changes in hidden Expert Advisor and dragged the first image I saw.



 
Alexey Viktorov #:

Have you tried a simple drag and drop of the picture?


out of 5 pictures only one is added

 
Andrei Trukhanovich #:

This has been the case for a long time. mql strings really don't like null characters inside a string and in literals, in functions too.

The only normal way is to convert three strings to an array with a terminating zero.

I.e. this behaviour as it is now was done deliberately a few years ago. I don't know the reasons.

There are enemies everywhere

 
Maxim Kuznetsov #:

In all interface DLL functions, wrap everything in try catch, catch the "unhandled exception" and log it...

It's a good idea to catch all exceptions and wrap all calls to pluses in try. Even in MQL documentation it's clearly written - DLL's shouldn't throw exceptions, not C++.

particularly conn.Close and new SqlConnection don't throw exceptions and could potentially throw one

Thanks! Checked it out, shared variable access error. The author wrote about it too.

It must be noted that the demo project has a very significant limitation: it allows to run only one Expert Advisor working with DB in one MetaTrader terminal. The matter is that all EAs use one instance of a loaded DLL. Since our class is made static, it will be the same for all running Expert Advisors. Variables will also be common. If you run several experts, they will all use the same connection and one command object for all. If several experts try to access these objects at once, problems may occur.


Q: How can I implement multi-threaded access to dll (separate instance for each function call and variables local for each call)?

 
2020.08.17 01:22:44   9842:0.8953065>0.92137
2020.08.17 01:22:44   9843:0.8953065>0.92106
2020.08.17 01:22:44   9844:0.8953065>0.92075
2020.08.17 01:22:44   9845:0.8953065>0.92045
2020.08.17 01:22:44   9846:0.8953065>0.92014
2020.08.17 01:22:44   9847:0.8953065>0.91983
        

2020.08.17 01:22:48   9842:0.8953065>0.92137
2020.08.17 01:22:48   9843:0.8953065>0.92106
2020.08.17 01:22:48   9844:1.7189865>0.92075
2020.08.17 01:22:48   Create GlobalVariables for SELL 1.7189865>0.92075
2020.08.17 01:22:48   9845:0.8953065>0.92045
2020.08.17 01:22:48   9846:0.8953065>0.92014
2020.08.17 01:22:48   9847:0.8953065>0.91983

I am experiencing this problem in the MT5 tester.

Working with multiple currencies, data is occasionally swapped from another currency. Check the tester. Please correct it.

The first value isSymbolInfoDouble(symbol,SYMBOL_BID);

2020.08.17 01:11:38   9877(EURGBP):0.8952471000000001>0.91079
2020.08.17 01:11:38   9878(EURGBP):0.8952471000000001>0.91048
2020.08.17 01:11:38   9879(EURGBP):0.8952471000000001>0.91017
2020.08.17 01:11:38   9880(EURGBP):1.7184123>0.90987
2020.08.17 01:11:38   Create GlobalVariables for SELL 1.7184123>0.90987
2020.08.17 01:11:38   9881(EURGBP):0.8952471000000001>0.90956
2020.08.17 01:11:38   9882(EURGBP):0.8952471000000001>0.90925
2020.08.17 01:11:38   9883(EURGBP):0.8952471000000001>0.90894
2020.08.17 01:11:38   9884(EURGBP):0.8952471000000001>0.90864

As if it cannot receive pricesSymbolInfoDouble(EURGBP,SYMBOL_BID); and takes value from another pair which is in work. Is there any way to check if the quote is correct?

 
SEM #:

Thank you! Checked it out, shared variable access error. The author also wrote about it

It should be noted that the demo project has a very significant limitation: it allows to run only one Expert Advisor working with DB in one MetaTrader terminal. The matter is that all EAs use one instance of a loaded DLL. Since our class is made static, it will be the same for all running Expert Advisors. Variables will also be common. If you launch several experts, they will all use the same connection and one command object for all. If several experts try to access these objects at once, problems may occur.


Q: How can I implement multi-threaded access to dll (separate instance for each function call and variables local for each call)?

There is almost no way to do this in .NET. The class is made static not because the author of the article is evil, but because that's how sharp classes are imported.

I see two ways: 1) (long time to write, works fast) rewrite in C++ and don't touch .NET anymore 2) (rather mechanically, but speed will go down and there could be side-effects) thoughtfully wrap calls in Critical Section to avoid two threads accessing simultaneously

if sharping is important, another option - to rewrite the connection pooling control at DLL level to remember the mapping of EA<->connection_id and every EA works with its connection;
I can not say about .net - is it possible to get and store reference to sharp's object in some MQL structure or scalar and pass it back and forth. That is to operate as with a normal C++ pointer. If you can, then everything is simplified.

Reason: