Discussion on "How to write a DLL for MQL5 and exchange data in 10 minutes". - page 7

 

pisara:

...IMHO the development of MT writing language should serve the specific tasks of trade, i.e. information gathering, analysis, testing, trade management and integration with other systems - all this can and IMHO should be done at a high level of modern development tools, i.e. by integrating and extending the selected standard framework using methods generally accepted in it (OOP, etc.). The task is not to write a closed and self-sufficient platform on a mixture of C/C++ or something else, but, first of all, to write the basics of trading platform, its services, API and user interface...

Moe IMHO is in complete agreement with your IMHO. It's nice to expose like-minded people. I associate MT with the proverb "the devil lurks in small things" and suspect serious architectural flaws, otherwise why are there so many "bricks" - "Hey citizen! Don't go there, go here! Or else the snow will fall on your head - you'll be completely dead!".

At the same time, you have to admit that MT is by no means the worst product I've had to deal with.

 

Renat писал(а) :

....MQL4.community already has articles about the Matad - MetaTrader 4 interaction:


Maybe I missed something, or maybe you miss something. I can't find any article about interaction between Matkad and MT4. Yes, I have Matlab. I have not got Matcad ((.

At one time I ordered MT4B<-> Matcad link to programmers. The only acceptable (stable) was communication via file operations. MT4-writes quotes into a file-Matkad reads-processes-puts results into a file (currency buy/sell)-MT4 reads and executes. But sometimes crashes for unknown reasons...spent more than 3 months but still no solution.

On the one hand your desire to do everything in one package, yes well and good. It's the stability and reliability of the system.

But on the other hand there are high level programming languages (Matlab, Matcad) for them so much has already been written, spent billions of man years. And to connect this power to MT5 would be great. You don't have enough strength or ability to reach the level of these languages...

P.S. I want to draw your attention, that both these languages are specialized to work with arrays (matrix algebra), exactly what you need...

 
Prival:

Perhaps I missed something, or maybe you misspoke. I can't find an article anywhere about the connection between Matcad and MT4. Matlab is there. But Matcab is not available ((.

Yes, I mixed up Matcad and Matlab. I'm sorry.


At one time I ordered MT4B<-> Matcad link to programmers. The only acceptable (stable) connection was through file operations. MT4-writes quotes into a file-Matkad reads-processes-puts results into a file (currency buy/sell)-MT4 reads and executes. But sometimes it crashes for unknown reasons... we spent more than 3 months, but still haven't been able to solve the problem.

Try to make a bundle with MQL5 - it's a more powerful, efficient and secure language.

You can start a public open work on the integration of Matkad with MT5 to get a good result. In this way both errors can be fixed quickly and the result can be good.

 
Renat писал(а) :
Yes, I have mixed up Matkad and Matlab. I'm sorry.


Try to make a bundle with MQL5 - it's a more powerful, efficient and secure language.

To get a good result, we can start a public open work on integration of Matkad with MT5. That way both errors can be corrected quickly and a good result can be obtained.

You can do a lot, but first of all I think it's you who should be interested in such projects (just imagine how your audience will increase and forex and exchange + writing programs on standard matlab ).

And public, open, etc work has not interested me for a long time. I too value my time. Tired of making mistakes like these.

//+----------------------------------------------------------------------------+
//|  Описание : Установка объекта OBJ_VLINE вертикальная линия                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    cl - цвет линии                                                         |
//|    nm - наименование                                                       |
//|    t1 - время                                                              |
//+----------------------------------------------------------------------------+
void SetVLine(string nm="", datetime t1=0, color cl=Red)
  {
  if (t1<=0) return; //t1=Time[0];
  if (ObjectFind(0,nm)<0) ObjectCreate(0, nm, OBJ_VLINE, 0, t1, 2);
  else Print("Ошибка создания SetVLine ",nm," ",GetLastError()," t1=",t1);
  
  ObjectSetInteger(0, nm, OBJPROP_COLOR, cl);
  ObjectSetInteger(0, nm, OBJPROP_STYLE, STYLE_DOT);
  ObjectSetInteger(0, nm, OBJPROP_BACK, true);        // рисовать как фон
  ObjectSetInteger(0, nm, OBJPROP_SELECTABLE, false); // запретить выделение объекта мышкой
  }

How can this procedure produce this ?

2010.05.06 02:28:14 Setka_Final_1 (EURUSD,M5) SetVLine creation error VLine_838524 4202 t1= 2010.05.06 00:00

This is bullshit.

ERR_OBJECT_NOT_FOUND

4202

Graphic object not found

If no object was found. The program should have created it. But the object is there if(...) so why does it get 4202.

Maybe I'm just tired and it's time to go to bed.

 

To Prival.

If you formulate an interesting enough MatCad problem (not very complicated to begin with), I am sure that there will be people who will be willing to join the task.

 
Prival:

2010.05.06 02:28:14 Setka_Final_1 (EURUSD,M5) Error creating SetVLine VLine_838524 4202 t1= 2010

If no object was found. Program should have created it. But the object exists if(...) then why 4202 is issued.

The error was left over from the previous function call. Use ResetLastError()
 


Good day! Speaking of passing strings into functions from DLL

I have the following code:

#include <WinUser32.mqh>.

#import "mt4excel.dll"

bool ExcelOpen();//opens Excel and creates a blank page

bool ExcelSetTextCell(int X,int Y,char Value[]);//Write text into the cell

/*

others cut

*/

#import

void OnTick()

{

MqlRates rates [];

int copied=CopyRates("EURUSD",PERIOD_M1,0,1,rates);

ExcelSetTextCell(1,1, "Tool");

ExcelSetTextCell(2,1, "EURUSD");

ExcelSetValueCell(2,2,rates[0];

}

As stated, Excel displays only the first letter of the one passed there using ExcelSetTextCell. After reading this thread, I figured out what the reason is, but I'm not quite sure how to get what I need. The point is that I didn't write the DLL, it's a library of functions for working with Excel via MT4. For obvious reasons MT5 takes a pointer to a string with only first character. The question is, how can I get MT5 to pass there what I need, if I can't edit the source code of DLL? As far as I understand, you need to add something like

_DLLAPI void __stdcall demo(char *stream, char*buf){ buf=stream;}

I would be grateful for comments from MT5 developers

Thank you!

 

ns_k, don't forget that strings in MQL5 are unicode.

There are 2 possible solutions.

1. Rework (modify) the dll to accept unicode strings

2. Convert string to an array yourself

 
stringo:

ns_k, don't forget that strings in MQL5 are unicode.

There are 2 possible solutions.

1. Rework (modify) the dll to accept unicode strings

2. Convert the string into an array by yourself

The second solution works for me. Tell me, do I have to change the declaration of the function too? I.e. instead of

bool ExcelSetTextCell(int X,int Y, string Value);//Write text in the cell

I have to write a declaration where the third parameter will be an array? If so, how to do it I don't understand. Thank you!

I figured it out though, I just had to think a bit. Thanks for the help!!!

 

Declaration of a DLL function

bool  ExcelSetTextCell(int X,int Y, uchar& Value[]);
Calling a DLL function
//--- объявляем массив символов
uchar value[];
//--- преобразуем юникод строку в однобайтный массив
StringToCharArray("EURUSD", value);
//--- передаем полученные данные массива по ссылке
ExcelSetTextCell(2,1,value);
Reason: