mt4R for new MQL4

0
(0)
Tên:
mt4R for new MQL4
Tác giả: micclly (2014.02.06 15:31)
Xếp hạng: 10
Đã tải xuống: 324
Tải xuống:
mt4R for new MQL4 1
mt4R-1.4.0-SNAPSHOT-b7.zip (152.0 Kb)
mt4R for new MQL4 2 00_README.txt (303 byte)

Sự miêu tả:

mt4R, originally developed by Bernd Kreuss and distributed đây, does not work correctly with new MQL4.

I modiifed the dll and the include file to support new MQL4.

Latest version:

You can get the latest version from GitHub releases. (Due to update time lag by moderation, the attached binary may be older than the latest release at GitHub)

Changelog is also at CHANGES.mdGitHub commits.

Update history:

Feburary 10, 2014: v1.4.0-b7: Added sample experts: Arb-O-Mat and Trend-O-Mat(GitHub#5).

Feburary 9, 2014: v1.4.0-b6: Fixed the bug of RGetBool/RGetInteger(Github#4).

Feburary 9, 2014: v1.4.0-b5: Fixed the bug of RAssignString(Github#3).

Feburary 9, 2014: v1.4.0-b4: Fixed the bug of RAssignStringVector(GitHub#1), and updated the minor version number in DLL hardcoded.

Feburary 7, 2014: v1.4.0-b1: Changed MQL file encoding to UTF-16

Feburary 6, 2014: v1.4.0-b0: Initial snpashot

Nguồn:

Source codes are distributed at a branch of my GitHub repository.

Ghi chú:

  • Testing is not enough
  • I had only confirmed that it seems work good with R-3.0.2 on Windows 2012 R2.
  • Performance may be slightly worse, because wide string in arguments is always converted to ansi string.
11 bình luận: 1 2 Để gửi bình luận mới, Xin vui lòng đăng nhập hoặc đăng ký

Thanks for your great work!

Tuy nhiên, the R chart created by Arbomat seems to come and go in a fraction of a second at the moment of loading the EA. What could be the reason?

R chart created by Trendomat is appearing good. I'm using the same PC and the same MT4.

Cũng, sometimes appears this message in the experts tab:

mt4R for new MQL4 3

13.02.2014 23:41 kaleb

TJmclovin:
Excellent job! Thanks for the instant fixes 🙂 !!!

Two more things:

  • RGetInteger: AExpression: PChar should be PWideChar and subsequently Result := TRConsole(AHandle).GetInteger(WideStringToString(AExpression, CP_ACP))
  • RGetBool: Same as above 🙂

Lại, thank your very much !

Great thank you and I'm sorry about terrible porting quality...

I've fixed RGetBoo/RGetInteger bug at v1.4.0-SNAPSHOT-b6.

 

BIÊN TẬP: Next time I'll just open an issue at your repo if you don't mind. I don't want to spam the comments section here ;)

 

I'll welcome for iissue from you if you feel to report something about this!

08.02.2014 21:08 micclly

Excellent job! Thanks for the instant fixes 🙂 !!!

Two more things:

  • RGetInteger: AExpression: PChar should be PWideChar and subsequently Result := TRConsole(AHandle).GetInteger(WideStringToString(AExpression, CP_ACP))
  • RGetBool: Same as above 🙂

Lại, thank your very much !

BIÊN TẬP: Next time I'll just open an issue at your repo if you don't mind. I don't want to spam the comments section here 😉

08.02.2014 20:46 TJmclovin

TJmclovin:
Thanks for fixing it! Works great! One more minor change is required though:
// assign string to variable given by name
procedure RAssignString(AHandle: LongInt; AVariable: PWideChar; AValue: PChar (should also be PWideChar?)); stdcall;
begin
  if isValid(AHandle) then
    TRConsole(AHandle).AssignString(WideStringToString(AVariable, CP_ACP), WideStringToString(AValue, CP_ACP));
end;

Thanks for bug report, I've fixed at v1.4.0-SNAPSHOT-b5.

Please update the dll and the include file, because of minor version number is changed from before b3.

08.02.2014 20:09 micclly

TJmclovin:
It crashes when trying to execute
Rf("lần",lần);

Thanks for your bug report!

From the investigation, the array processing in RAssingStringVector is not correctly ported to new MQL4.

I've updated the DLL, so please get the latest version from GitHub.

In this version, DLL-hardcoded minor version number updated to 4, so please also copy MQL4/Include/mt4R.mqh.

08.02.2014 19:54 micclly

Thanks for fixing it! Works great! One more minor change is required though:

// assign string to variable given by name
procedure RAssignString(AHandle: LongInt; AVariable: PWideChar; AValue: PChar (should also be PWideChar?)); stdcall;
begin
  if isValid(AHandle) then
    TRConsole(AHandle).AssignString(WideStringToString(AVariable, CP_ACP), WideStringToString(AValue, CP_ACP));
end;
08.02.2014 19:51 TJmclovin

Trước hết: Thank you so much for porting it to the new version! Excellent job!

Tuy nhiên, I've encountered a problem. See this simple script:

//+------------------------------------------------------------------+
//|                                                  TestNewMt4R.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"
#property strict

#include <mt4R.mqh>

#define RPATH "D:/Program Files/R/R-3.0.2/bin/i386/Rterm.exe --no-save"
#define RDEBUG 2

string times[1000];
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   StartR(RPATH,RDEBUG);
   vì(int i=0; Tôi<1000; i++)
     {
      lần[Tôi]=TimeToString(iTime(Biểu tượng(),Giai đoạn(),Tôi),TIME_DATE|TIME_SECONDS);
     }
   Rf("lần",lần);
   Rx("gc()");
   StopR();  
  }
//+------------------------------------------------------------------+

It crashes when trying to execute

Rf("lần",lần);

And I don't know why. I think the problem might be the one you mentioned regarding strings. Tuy nhiên, I cannot resolve it by myself so help is very much appreciated.

Cảm ơn!

BIÊN TẬP:

I checked DebugView and it seems that the whole String handling is somehow broken, ví dụ.,

void OnStart()
  {
   StartR(RPATH,RDEBUG);
   string testString = "This is a string copy test.";

   Rs("rString", testString);

   Rx("gc()");
   StopR();
  }

Results in:

Wrong copy of string

08.02.2014 16:28 TJmclovin

Thanks for the explanation, and the update!
07.02.2014 08:57 FXEZ

FXEZ:
Can you specify what changes were necessary to update the dll? I wasn't aware that dlls need to be changed to fit MQL5's format. Have you any links on this subject?

string in new MQL4 is not an array of char but an array of wchar_t.

If your old indicator/script/EA which worked on MT4 build509 or earlier uses string and passes it to DLL functions, you MUST change the function to wchar_t phiên bản.

Ví dụ, if it uses ShellExecuteA, change it to ShellExecuteW.

Unfortunately if the dll you use does not provide wchar_t version functions like mt4R.dll, you must modify DLL implementation, or convert an string to an array of char qua WideCharToMultiByte Win32API.

Ghi chú: I haven't tried WideCharToMultiByte yet on new MQL4, so I don't know you can use WideCharToMultiByte without or with any problem.

At the xây dựng 600 release topic, it is said as follows:

Changes in MQL4 Language

  • Strings are now presented in Unicode format, though they were in ANSI format (single byte ones) before. That should be considered if the program uses DLLs and passes string variables to them. When calling Windows API functions, Unicode versions of these functions should be used.
07.02.2014 07:07 micclly

acushnir:
Thanks for your contribution.

It's nice to know somebody takes care about useful projects.

best regards

Can you specify what changes were necessary to update the dll? I wasn't aware that dlls need to be changed to fit MQL5's format. Have you any links on this subject?

Bài đăng này hữu ích như thế nào?

Bấm vào một ngôi sao để đánh giá nó!

Đánh giá trung bình 0 / 5. Số phiếu bầu: 0

Không có phiếu bầu cho đến nay! Hãy là người đầu tiên đánh giá bài viết này.

Chúng tôi xin lỗi vì bài đăng này không hữu ích cho bạn!

Hãy để chúng tôi cải thiện bài đăng này!

Hãy cho chúng tôi biết cách chúng tôi có thể cải thiện bài đăng này?



Tác giả: Nhóm ngoại hối Wiki
Chúng tôi là một nhóm gồm các Nhà giao dịch ngoại hối giàu kinh nghiệm [2000-2023] những người cống hiến để sống cuộc sống theo cách riêng của chúng ta. Mục tiêu chính của chúng tôi là đạt được sự độc lập và tự do về tài chính, và chúng tôi đã theo đuổi việc tự học và có được nhiều kinh nghiệm trong thị trường ngoại hối như là phương tiện của chúng tôi để đạt được lối sống bền vững.