Discussion of article "Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#" - page 5

 
Igor Makanu:

in the article there is a completely different way of MT5 interaction with the "outside world", you need to describe signatures of C++ functions in MT5 code and call them as a normal dll, here is a working example, I tested it a month ago.

https://www.mql5.com/en/articles/18

HI: tensorflow c# is perfectly googleable, here are ready solutions for C# https://nugetmusthaves.com/Tag/tensorflow 

Good article, I'll take note, thanks!

I already know that tensorflow c# is perfectly googleable, I just don't want to spend time on learning C#, so I integrate tensorflow with C++.

That was not my question.

What is the difference between the way of interaction described in the article and the usual one? It is written in the text that it is just enough for the dllka to be written on the .Net platform. But you don't have to use C# to write on that platform. But when I use C++/CLR (and Visual Studio suggests that I get an application with .Net classes), MQL5 still requires to declare functions from the resulting dllka as usual, and does not see classes at all.

 

Is it possible to send a string from Visual Studio to MT5? How can I do this?


Thanks for your help

 
AikAcrobatt:

What is the difference between the way of interaction described in the article and the usual way? The text says that it is simply enough for the dllka to be written on the .Net platform. But you don't have to use C# to write on this platform.

If I'm not mistaken, the method used in the article is called C# injection - google it, I'm no help here, how the interaction between C# and MQL5 takes place, as an option "spin" the example https://www.mql5.com/ru/forum/303283/page3#comment_10607873.

Обсуждение статьи "Создание графических интерфейсов для экспертов и индикаторов на базе .Net Framework и C#"
Обсуждение статьи "Создание графических интерфейсов для экспертов и индикаторов на базе .Net Framework и C#"
  • 2019.02.12
  • www.mql5.com
Опубликована статья Создание графических интерфейсов для экспертов и индикаторов на базе .Net Framework и C#: Автор: Vasiliy Sokolov...
 
fxsaber:

Is it realistic to show an example of using, for example, this library?

The library is interesting. I think it is quite realistic to integrate it with the engine.

 
AikAcrobatt:

Hello, this is a great article!

There are a number of questions arising from the above:

1) From the text of the article I got the impression that not only graphical interfaces, but also the implementation of almost any API that "does not fit" in MQL5 can be organised in the same way.

Yes, it is absolutely true. The article essentially describes a modified MVC design pattern. Patterns are universal and do not depend on language tools and tasks, the main thing is that the concept of 'model-representation-controller' fits well into the task.

AikAcrobatt:

My question is, is it possible to write a C++ .Net library (I understand using C++/CLR) so that MQL5 can be implemented in its .Net code like in your GuiController engine? ...?

2) Theoretically you can. Net dll is a packed CIL into which high level languages like C#, VB Net, C++ Net are translated. I.e. MQL should read net dll no matter what language it was written in. But only how it will be in practice should be checked, because the developers obviously intended to use C#.

AikAcrobatt:

The practical example I'm interested in is this. Nowadays there are possibilities to integrate opsensor libraries on machine learning with VS2017, and for example TensorFlow provides API in C++ with support for GPU computing. Your article provides a great opportunity to integrate C++ implementation of TensorFloW (or any other machine learning library) directly into MQL5, which seems very convenient to me. The problem is that for some reason I can't even import a trial C++ dll into MQL5 using the method specified here.

Do you mean Net C++ dll? If yes, you should check and see. It is difficult to understand how it will work in reality.

But in general, you are very right: fast integration with existing code is definitely the future. And you will not have enough time to write everything yourself. And here you can download what you need and go ahead.

 
AikAcrobatt:

...

What is the difference between the way of interaction described in the article and the usual way? The text says that it's just enough to have a dllka written on the .Net platform. But you don't have to use C# to write on that platform. But when I use C++/CLR (and Visual Studio suggests that I get an application with .Net classes), MQL5 still requires declaring functions from the resulting dllka as usual, but it doesn't see classes at all.

This is very strange, because everything works quite differently with C#. MQL perfectly sees Net classes and their methods with signatures. Even intellisense works in MetaEditor.

Unfortunately, I am almost inexperienced in C++. I would be glad to help you, but I'm afraid I won't be able to.

 
Norton Daniel Barth:

Is it possible to send a string from Visual Studio to MT5? How can I do this?

Thanks for your help

Yes, of course. You can return the string from a method (line 1). You can also return the string from a reference (line 3):

string line = SharpClass::GetSting();
string line_l;
SharpClass::GetStringByLink(line_l);

Where SharpClass is the static C# class in your assembly.

 
Vasiliy Sokolov:

This is very strange, because everything works quite differently with C#. MQL sees Net classes and their methods with signatures perfectly. Even intellisense in MetaEditor works.

Unfortunately, I am almost inexperienced in C++. I would be glad to help you, but I'm afraid I won't be able to.

So far I have the following:

The simplest dllka in C++ using .NET:

using namespace System;

namespace TesterMQL54 {
        public ref class Class1
        {
        public: static int Func1(int arg) { return (arg - 1); };
        };
}

This library interacts with MQL5 in the same way as a similar one in C# (I checked) and similar to the one described in your article.
When we insert the programme into MQL5:

#import "TesterMQL5_4.dll"
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
void OnStart()
  {
   Print("Beg");
   Print(Class1::Func1(7));
   Print("End");
  };
//+------------------------------------------------------------------+


Everything compiles, the compiler sees class Class1 and function Func1. But unlike the Sharpe behaviour, the terminal says that it fails to load the dll:

Cannot load 'C:\Users\...\MQL5\Libraries\TesterMQL5_4.dll' [0]

EX5 loading failed.



 
Vasiliy Sokolov :

Yes of course. The string can be returned from the method (string 1). You can also return the string reference (row 3):

Where SharpClass is a static C # class in your assembly.

Thanks for your help, but I need to learn more about C #, I can really make this simple thing work or include the code


Thanks again for your time

 
AikAcrobatt:

I've got the following so far:

A simple dll in C++ using .NET:

...

Please insert the code correctly: