Websocket how? - page 13

 
Igor Makanu:

Still something's wrong, in theory this code should work.

C#

MQL5

I get compile errors, that t1 parameter cannot be converted

MqlTick type defined in C# and MqlTick type defined in MQL are different types.
Change the type name in Sharp and work only with this type
Or copy returned values into Mql type

 
Vladimir Suslov:

MqlTick type defined in C# and MqlTick type defined in MQL are different types.
Change type name in Sharp and work only with this type
or copy returned values to Mql type

haven't tested it (PC is busy with network hanging city!!!),

but i think it will work as you write

there is no proper MQL-C# exchange documentation in general, my example uses structure field alignment, in yours the fields are of the same size, and if there are other types, what will happen when exchanging data? - I suspect that at best it will be a time error, at worst - data loss.

There's a good article about structure handling in C# on Habra, I remember, that in C# it's default alignment, but in MQL it's the opposite - I'll find it later, when I'm free.

 
Igor Makanu:

didn't check (PC network hanging city busy!!!),

Network city seems to be dead everywhere. Ours in Volgograd is hovering too. Miracle site )))

 
Igor Makanu:

haven't tested it (the networked city PC is busy!!!),

But I think it will work as you write

there is no proper MQL-C# exchange documentation, my example uses structure field alignment, in your example the fields are of the same size, and if there are other types, what will happen when exchanging data? - I suspect that at best it will be a time error, at worst - data loss.

there is a good article on Habra about working with structures in C#, i remember that in C# the alignment is default, but in MQL it is vice versa - i will find it later, when i have enough space on my PC

I gave an example with a simple structure with two dubs.
There is nothing to align.
A more complex structure may need alignment.
This has to be checked.

ps the network is ok)

Документация по MQL5: Основы языка / Типы данных / Структуры, классы и интерфейсы
Документация по MQL5: Основы языка / Типы данных / Структуры, классы и интерфейсы
  • www.mql5.com
Структура является набором элементов произвольного типа (кроме типа void). Таким образом, структура объединяет логически связанные данные разных типов. Объявление структуры Имя структуры нельзя использовать в качестве идентификатора (имени переменной или функции). Следует иметь ввиду, что в MQL5 элементы структуры следуют непосредственно друг...
 
Алексей Барбашин:

Fedor, there is only one last test case left: getting tick structure from sharp to mql. Think about how to implement it, all the examples are here, Volodya showed how to get data as structure from sharp.

I am waiting for the final result.

I'll do it now. What do you think? Will it work in MT4?
 

I did. I sent you a message via chat


 
Алексей Барбашин:

If you need to transfer large amount of heterogeneous information then it's better to do the same way as web socket works: pack the information on sharp side into json, encode into string and return it as string, and do reverse conversion on mql side. It works very fast, i tested it. :)

But it's better to use regular methods, e.g. the same structures, if possible. :)

No, I need structures, the structures are practical, thanks. I now have a clear vision of how things work in C# + MQL5.


Vladimir Suslov:

I gave an example with a simple structure with two dubs.
There is nothing to align.
For a more complex structure you may need alignment.
This needs to be checked.

ps the network is ok)

I found an article about structures in C#https://habr.com/ru/post/114953/

all in all there is enough material to work with, thanks

 

I'm going to cut in a bit, since all the actors are probably tired of the show

what happens to memory/cpu consumption, especially when running a couple of these EAs at the same time ?

they don't get overpowered if they are started from the same process ?

In my humble opinion, an unfinished (so far) recipe is to take Socket MQL and make http+websocket in it to a minimum. At least it will work on VPS metaquotes. Of course this is a sunset by hand, but look at articles - so even MySQL is addressed in this way

 
Fedor Arkhipov:
I will do it now. What do you think? Will it work in MT4?

only through the method from the articlehttps://www.mql5.com/ru/articles/249

MQL4 does not know how to call managed code, or write a wrapper in C++ and use it to call .Net or the article above, I checked the article last year - everything works, but there is a lot of work - many pitfalls, if you are interested don't start, you need a lot of time to google material when problems arise

 
Maxim Kuznetsov:

I'm going to cut in for a bit, on the good grounds that all the actors are probably tired from the play


You can rent a normal Windows VDS and run it from a DLL, you can run multiple terminals at the same time.

Reason: