Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1498

 
Mikhail Toptunov string type parameter

If I output aS[0] array via Print(), the font is different from the rest.


If you just print the parameter tr , then = 0

Have you tried looking at the file itself?

you are writing binary values and reading a text string....

 
Maxim Kuznetsov #:

Have you tried looking at the file itself?

you are writing binary values and reading a text string...

I imported it like this

void OrderImport(MqlTradeRequest &aReq[], int magic, string symbol)
  {
   ArrayFree(aReq);
   long tr;
   static long trans = 0;
   if(trans == 0)
      trans = TimeGMT() - 1;
   string file = "OrderExchange" + (magic > 0 ? IntegerToString(magic) : "") + ".csv";
   int handle = FileOpen(file, FILE_READ | FILE_SHARE_READ | (Common ? FILE_COMMON : 0));

like this for export

void OrderExport(MqlTradeRequest &request)
  {
   static long trans = 0;
   static long keepTrans = 0;
   string file = "OrderExchange" + (request.magic > 0 ? IntegerToString(request.magic) : "") + ".csv";
   int handle = FileOpen(file, FILE_READ | FILE_SHARE_READ | FILE_WRITE | FILE_SHARE_WRITE | (Common ? FILE_COMMON : 0), ';');

became better, but the first import of the first parameter string (aS[0]) is always an error.


next

tr - reflects translated string in int(aS[0])

The file is viewed, everything is in its place.


But importing the first parameter aS[0] of the first line does not translate it into int.
 
Aleksandr Slavskii #:

If you don't initialise an array, it often contains rubbish.

Thanks, I even remembered that I've encountered this before (0 confused me). It is a pity that it is not specified in the documentation, I have to keep such things in my head.

 
Mikhail Toptunov #:

imported

like this for export

better, but the first import of the first parameter string (aS[0]) is always an error.


next

tr - reflects translated string in int(aS[0])

The file is viewed, everything is in its place.


But importing the first parameter aS[0] of the first line does not translate it into int.

How can this be? - the first aS[0] is always broken (error 5040)


 
Kind people, please give me a hint. I have a task to run optimisation, but for optimisation I need to use external data. I did this: I created a file with data and at each pass I open the file, write to the array and close it. How can I optimise and speed up this process?
 
Mikhail Toptunov #:

How can this be? - the first aS[0] is always broken (error 5040)


set UTF-8 encoding in Export and Import (or at least the same one-byte encoding without BOM).

(look at the file in binary form - the first two bytes are probably BOM, i.e. it is Unicode) - when you FileSeek(0,SEEK_SET) and then read, you read them into a string and the conversion fails.

 
Maxim Kuznetsov #:
BOM

Well, it seems to have worked. True once still does not reflect, but then when you delete the file at least stopped glitching.


FILE_CSV | FILE_READ | FILE_SHARE_READ | FILE_ANSI | (Common ? FILE_COMMON : 0),CP_UTF8

Thank you very much!

 

Good morning and good mood!

I encountered the lack of ResultRetcodeExternal description in the MQL5 Reference Manual. In the search engine I get the following answer: Nothing was found for your request. In a roundabout way, I found that it seems to be "Error code returned by an external trading system. The spelling and types of these errors depend on the broker and the external trading system to which the trade operations are output".

Question: did I find the correct definition or not?

And at the same time the second question to the developers of documentation: if it is so, why don't you immediately provide users with full information, instead of making them look anywhere for what this definition is?

Regards, Vladimir.

 
MrBrooklin #:
ResultRetcodeExternal

You won't find such a thing. It does not exist in MQL5.

There is MqlTradeResult, where there is a field retcode_external, and where there is a description of this field.

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
  • www.mql5.com
Структура результата торгового запроса - Структуры данных - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin #:

You won't find such a thing. It doesn't exist in MQL5.

There is MqlTradeResult, where there is a field retcode_external, and where there is a description of this field.

Thank you for your answer, Artem, but honestly, I don't quite understand what "not available in MQL5" means? And then in the picture in the included file Trade.mqh in the highlighted line, what is it?

By the way, through this line I came to m_result.retcode_external, and then to MqlTradeResult, where I found the description I needed. That's where the questions arose from.

Regards, Vladimir.

Reason: