View Full Version : MQL4 -gt R-Project - Interface Library
oxmiooxleo1006
12-13-2022 22:42,
Have you downloaded the updated DLL and MQL documents out of here? Https://www.mql5.com/en/code/11112
Have you followed FXEZ' directions https://www.nigeriaforextrading.com/trading-discussion/73-trade-curve.html?
guffoxan
12-13-2022 22:50,
Hi guys!
I m using Windows 7 and also the previous version of MT4R.mqh and dll files... I've an issue since several cases of my EA (one per instrument) running simultaneously attribute the same integer as a deal for R.. . Perhaps because the integer is described using the internal clock of the processor and also that calling the RInit function at the same time increases the odds of getting the same integer? Any idea about how to solve this? I might place RHandle for every currency pair as international factors, assess these factors and deinitialize-reinitialize R until I get various integers as handles but I was wondering if there was a much better alternative....
Thanks!
Try Microsofts version of R called MRO. mran.revolutionanalytics.com. Multiprocessor support and a Math library that is discretionary to install for performance.
Dear all!
Thank you for this fantastic information pool . It made me more interested https://www.nigeriaforextrading.com/attachments/1530270782.png
that I wasn't able to make it function following instructions . (silly me)
For initial testings I just started with basic indior. I suppose I have a communiion problem.
Framedata:Acquire 10 x64 ( neighborhood kvm guest ) - Host is running arch (should not matter) Metatrader4 4.00 buil 971 - 7jun2016 R 3.3.0 out of r-project. org precompiled mt4r.dll from here https://github.com/micclly/mt4R The indior: (out of this thread )
Inserted Code #property copyright Bernd Kreuss #property indior_chart_window #property indior_buffers 1 #property indior_color1 Crimson #property indior_width1 two #include lt;mt4R.mqhgt; extern int order = 200; extern int back = 500; extern int forward = 20; int R; dual buf_prediction#91;#93;; int init() SetIndexBuffer(0, buf_prediction); SetIndexStyle(0, DRAW_LINE); SetIndexShift(0, forward ); //R = RInit(C:/Apps/R/R-3.3.0/bin/i386/Rterm.exe --no-save, 2); // tried several syntaxes? R = RInit(C:\\Programs \\R\\R-3.3.0\\bin\\i386\\Rterm.exe --no-save, 2); Comment(history: rear pubs, method: OLS, order: order); int deinit() RDeinit(R); int start() dual hist#91;#93;; dual pred#91;#93;; int I; should (RIsBusy(R)) // final RExecuteAsync() is still not completed, do nothing. Return(0); if (RGetInteger(R, as.integer(exists('version'))) == 1) // there is a version (the factor is set). // This means a formerly started RExecuteAsync() has completed. // we are now able to forecast from this version and plot it. RAssignInteger(R, forward, forward ); RExecute(R, pred lt;- predict(model, n.ahead=forward )$pred); ArrayResize(pred, forward ); RGetVector(R, rev(pred), pred, ahead); for (I=0; ilt;beforehand; I ) buf_prediction#91;I#93; = pred#91;I#93;; // create a (new) prediction // move some history around to R ArrayResize(hist, back); for (I=0; ilt;backwards; I ) hist#91;I#93; = Close#91;I#93;; RAssignVector(R, hist, hist, ArraySize(hist)); RExecute(R, hist lt;- rev(hist)); // crunch the numbers in the backdrop and return from the start() function // RIsBusy() in the next ticks will inform us when It's finished. RAssignInteger(R, ord, order); RExecuteAsync(R, version lt;- ar(hist, aic=FALSE, order=ord, process ='ols')); return(0);
All includes came from Github mentioned above.
This is my debug log, as you can see out is empty constantly =?
Http://pastebin.com/UyW8zidL
EDIT:
As of writing this, it worked allready https://www.nigeriaforextrading.com/attachments/1530270782.png (stupid me). It took a long time. ( CPU felt like idle all the time? )
Anyhow I allow that post here for the next to come here from google.
Question:Can there be an speed improvement using 64bit mt4r.dll? (dont know ho to compile one - I am no windows guy) Or is there an dll communiion with R implementation Boa said in 183? Other tips here? https://www.nigeriaforextrading.com/attachments/1530270782.png
lobokefl
12-13-2022 23:57,
Help me! I have a problem when I drag indior into char 1H. How can I fix that?
https://www.nigeriaforextrading.com/attachments/1530270799113330816.png
You want to allow dll import.
https://www.nigeriaforextrading.com/attachments/1530270784.png
lobokefl
12-14-2022 00:21,
#8203;Thank you for help! Indior 7bit not work, although that problem is solved. Just how I can fix?
https://www.nigeriaforextrading.com/attachments/15302708021668974707.png
There's a problem is not specific. I suggest You need to read this thred. There are many tips in here the best way to solve Problems....
DebugView.exe is a good place to begin...
lobokefl
12-14-2022 00:47,
Thank you Very much! I am used DegugView and possess a incorrect (this time is not problem). Help me continue! I am newbie so because bothered you too much excuse me. Your help is quite significant for me.
https://www.nigeriaforextrading.com/attachments/15302708041861194406.png
lobokefl
12-14-2022 01:04,
Perhaps it working
https://www.nigeriaforextrading.com/attachments/1530270806318614436.png
Yes, try that button:
https://www.nigeriaforextrading.com/attachments/1530270808899118286.png
fabiolixxabaza
12-14-2022 02:05,
new version: added RAssignMatrix() added RAssignFactor() along with some different things. file file Hallo 7Bit,
I have trouble useing your R-Sample. Indior, should I compile it I get one error I don't understand what to do with it?
'DbgLog' -purpose not defined
please visit the picture below....
Https://www.nigeriaforextrading.com/attachments/15302708102075645006.png
Can someone help me with this? https://www.nigeriaforextrading.com/attachments/1530270790.png
Regards
Mikolomg
12-14-2022 03:03,
Hi
Has anybody trade this with profit?
Mompecomazokes96
12-14-2022 03:09,
Hello men,
I've an indior that has to connect with R tender. But it is advised that R should install some packages such as PKI, deepnet, quantmod, and RSSNS. But when I do these all the indior dependencies shows some function icons that are reddish.
Can you guys have no clue what the problem is.
Nombempkmaba
12-14-2022 03:18,
The Best Way to Interface Python/R Trading Strategies with MetaTrader 4: https://blog.darwinex.com/zeromq-interface-python-r-metatrader4/
Inserted Video https://www.youtube.com/embed/GGOajzvl860?origin=https://www.forum.com
bycho2818
12-14-2022 03:25,
Hello Men,
Anyone has script that can simulate information extraction through weekend aka onetick (Old version)
* send exactly one bogus tick into the chart and
* all its indiors and EA and then exit.
bmunamoox
12-14-2022 03:32,
Hello Guys, Anyone has script which may simulate data extraction during weekend aka onetick (Old version) * ship exactly one bogus tick to the chart and all its indiors and EA and then depart. ShinjiOno Hi Ono,
together with the Arrival of Megatraitor B6XX and succeeding all strings are now WideChars rather than simple AnsiChars.
So everywhere whenever the script posts a message in the operating system with the tag MetaTrader4_Internal_Message then the acompanying W-Functions of the operating system are to be used.
This creates a PostMessage() a PostMessageW() call and a RegisterWindowMessage() a RegisterWindowMessageW() call.
Here's the script working with B6XX and over.
daijo bu des ka
Inserted Code /** * MT4/experts/scripts/one_tick. Mq4 * send exactly one bogus tick to the chart and all its indiors and EA and exit. */ #property copyright © Bernd Kreuss #import user32.dll int PostMessageW(int hWnd, int Msg, int wParam, int lParam); int RegisterWindowMessageW(string lpString); #import int start() int hwnd = WindowHandle(Symbol(), Period()); int msg; for (int I=1; ilt;20; I ) msg= RegisterWindowMessageW(MetaTrader4_Internal_Messag e); PostMessageW(hwnd, msg, 2, 1); Sleep(100); return(0);
semgiooxikel
12-14-2022 03:39,
Btw, here is a way, say an idiom, for this particular R-MT4 library.
Idea:
-you don't wish to app R MQL code by conenating strings together. You would like to do this at R.
-MQL is simply intended for 3 points: passing data to retrieving results back from R and then showing it.
-if you wanna alter your R code/algorithm, you wan na na do that ONLY in your R code WITHOUT changing your MQL code.
(so basically, you write your MQL code and you'never' alter it).
And this is how you do this:
Inserted Code... // get your Tick data and put it in a variety ArrayResize(histC, back); ArrayResize(histH, back); ArrayResize(histL, back); for (I=0; ilt;back; I ) histC#91;I#93; = Close#91;I StartFrom#93;; histH#91;I#93; = High#91;I StartFrom#93;; histL#
AngmeaOxyom
12-14-2022 03:46,
http://codebase.mql4.com/9226 Name: mt4R for new MQL4 Writer: http://www.mql4.com/users/micclly (2014.02.06 15:31) Description: mt4R, initially developed by 7bit and dispersed http://www.mql4.com/go?https://sites.google.com/site/prof7bit/r-for-metatrader-4, does not work properly with new MQL4. I modiifed the and that the dll include file to encourage new MQL4. Thank you so much sanami! I had everything and utilized your dll. Fantastic work!
Julay21Celina
12-14-2022 03:56,
Hello,
Who reads in Russian - intriguing appliion of R.
Article The third generation of neural networks: Deep neural network.
Https://www.mql5.com/ru/articles/1103
good fortune
P3mc3v4l
12-14-2022 04:04,
For your programmers, you may get this attached document helpful concerning some of the ways to directly access R.exe / Rterm.exe in batch mode.
Working With R in batch Mode: A few notes for beginners by Michael Lundholm
people.su.se/p lundh/reproduce/batchmode.pdf
I will access 7Bit's dll from C# (in a 32 bit program) but neither of the two new variants (Naddmer / micclly) from C# - any idea why? When compiling the original edition maybe 7Bit used some.
Also, has anyone compiled the mt4R dll in 64 bit? It would be wonderful to have the ability to use this project. I am aware of other choices for C# R. But after studying the attached paper I begin to wonder why I do not roll my own course? It couldn't be that hard could it? lt;ggt;
https://www.nigeriaforextrading.com/attachments/15302708341777788312.pdf
Julay21Celina
12-14-2022 04:20,
For the developers, you might find this attached document helpful concerning a few of the strategies to immediately access R.exe / Rterm.exe in batch mode. Working With R batch Mode: Some notes for beginners by Michael Lundholm people.su.se/p lundh/reproduce/batchmode.pdf I will access 7Bit's dll out of C# (in a 32 bit program) but neither of the two new versions (Naddmer / micclly) out of C# - any idea why? Perhaps some was used by 7Bit when compiling the first version. Has anyone compiled the mt4R dll in 64 bit? It would be wonderful to be able to... Hello,
1. MT4R.dll - a gateway for information transmission in text form from the MT4/MT5 terminal in Rterm and receiving result back. Anything more
2. Calculations in the terminal can be made on each tic. Batch mode for such calculations -- absurdity.
good luck
Julay21Celina
12-14-2022 04:30,
Hi,
Now and in English
https://www.mql5.com/en/articles/1103
Great luck
P3mc3v4l
12-14-2022 04:40,
Those of you that are currently using this project might wish the R session to never shut down. You can fix it to constantly disregard errors by doing something like this (untested) edit in your mt4R.mqh file:
Inserted Code void StartR(string path, int debug=1) hR = RInit(route, debug); if (hR ! ) = 0) Rx(options(error=dump.frames)); // prevent R session from shutting down on a mistake Rx(options(device='windows')); // enable chart display within R
I have tested the options(error=dump.frames) line in my code and it seems to work in preventing R from shutting down on the very first error.
I will also report that the ideas described in the quote below (M. Lundholm newspaper ) are useful for making an interface to get R straight. I have a rudimentary R control line presentation project ready to go.
For the developers, you might find this attached document useful concerning a few of the ways to directly access R.exe / Rterm.exe in batch mode. Working With R in batch Mode: A few notes for novices by Michael Lundholm people.su.se/~lundh/reproduce/batchmode.pdf I will get 7Bit's dll from C# (in a 32 bit app ) but neither of the two new versions (Naddmer / micclly) from C# - any idea why? When compiling the first version 7Bit utilized some super kung-fu. Has anyone compiled the dll in 64 bit? It would be nice to be able to...
yzay1986
12-14-2022 04:47,
Hello everybody!
Failed to get set up to operate with P through mt4r. I think a easy task, but I can not understand. Please assist. I made a very simple functionR_test which returns the amount multiplied by 2. Nevertheless, the 2nd alert returns 0.
Inserted Code void OnStart() //-- R=RInit_(C:\Program Files\R\R-3.1.1\bin\x64\Rterm.exe --no-save,2); Alert(R); int a_=5; Alert(before R:,a_); Alert(After R,R_test(a_)); //-- //-- int R_test(int inp) int res; RAssignInteger(R,a,inp); RExecute(R,alt;-a*2); res=RGetInteger(R,a); return(res);
bmunamoox
12-14-2022 04:56,
... failed to get set up to work with P through mt4r. I believe a simple task, but I can notunderstand. Please assist. I made a functionR_test which yields the amount multiplied by 2. Nevertheless, the 2nd alert yields 0. ...
Inserted Code R=RInit_(C:\Program Files\R\R-3.1.1\bin\x64\Rterm.exe --no-save,2); Change that to C:\Program Files\R\R-3.1.1\bin\i386\Rterm.exe --no-save, please.
Rationale: MT4 is a 32bit appliion. Calling a 64 bit appliion may not work well.
Non - and wash up the R handle when shut down the script/indior/EA Utilizing RDeinit(R); in the void deinit() of MQL.
You may also get DBGVIEW.EXE from here https://technet.microsoft.com/en-us/library/bb896647.aspx to see the messages in the DLL as they don't show up in the MT4 logs.
P3mc3v4l
12-14-2022 05:01,
Bistreevseh,
Alter the slashes on your path from \ to / as R anticipates the latter.
I've used 64 bit R with mt4r.dll without difficulties. The calls to Rterm.exe are programmatically created through the command prompt so it shouldn't matter whether you select 32 or even 64 bit R as the OS does the hefty ling. It will not matter that mt4r.dll is 32 bit due to MT4 becoming 32 bit.
bmunamoox
12-14-2022 05:12,
bistreevseh, Switch the slashes in your path from \ to / as R anticipates the latter. I've used 64 bit R with mt4r.dll without difficulties. The actual calls to Rterm.exe are programmatically made through the command prompt so that it shouldn't matter if you choose 32 or 64 bit R because the OS does the heavy ling. It will not matter that mt4r.dll is 32 bit because of MT4 becoming 32 bit. Bistreevseh,
FXEZ is almost completely right about the slashes. Silly me.
A single \ simply escapes the following character in MQL4.
But but but then again. . .ye olde R-Sample from Master 7bit has....
Inserted Code // set this so it points into a R installation. Do NOT remove the --no-save extern series RPATH=C:\Apps\R\R-3.1.1\bin\i386\Rterm.exe --vanilla --no-save; #define RDEBUG 1
And if I operate that olde sample then it looks like that (DBGVIEW.EXE in foreground):
https://www.nigeriaforextrading.com/attachments/1530270838683601802.png
Therefore there must be a third cause of the error. Mind taking a look into DBGVIEW?
Edit: Win7 i386, newest patches.
yzay1986
12-14-2022 05:32,
Thank you very mutch! It is true.
yzay1986
12-14-2022 05:38,
Dear friends!
There's a new problem. In the debugger not very fantastic to observe the processes which keep coming back because two mistakes:
Inserted Code #91;4836#93; exception 40010007 at 7651C41F in C:\Windows\syswow64\KERNELBASE.dll EXCEPTION_CONTINUE_SEARCH #91;4836#93; exception 80000003 at 017F224E in C:\Program Files (x86)\Alpari Limited MT4\terminal.exe EXCEPTION_CONTINUE_SEARCH I'm use auto.arima() for calculates. This function is executed not properly some times. Please allow me to. I have mistakes even launch terminal. Tester egies are used by me maybe it is the cauce of mistakes.
My R :
Inserted Code int OnInit() //-- R=RInit_(C:/Program Files/R/R-3.1.1/bin/x64/Rterm.exe --no-save,1); RExecute(R,library(forecast)); //-- return(INIT_SUCCEEDED); // ------------------------------------------------------------------ //| Expert deinitialization function | // ------------------------------------------------------------------ void OnDeinit(const int reason) //-- RDeinit(R); /------------------------------------ int R_calculates(double arr#91;#93;-RRB- int res=0; RAssignVector(R,goal,arr,ArraySize(arr)); RExecute(R,errorlt;-0); RExecute(R,trainlt;-ts(target)); RExecute(R,trainlt;-rev(train)); RExecute(R,arimalt;-auto.arima(train)); RExecute(R,forecastlt;-forecast(arima,1)); RExecute(R,resultlt;-as.numeric(forecast$imply )); res=RGetInteger(R,result); return(res);
bmunamoox
12-14-2022 05:50,
Dear friends! There is a new problem. From the debugger not quite fantastic to observe the procedures which keep coming back since 2 errors: [4836] exclusion 40010007 in 7651C41F in C:\Windows\syswow64\KERNELBASE.dll EXCEPTION_CONTINUE_SEARCH [4836] exclusion 80000003 in 017F224E in C:\Program Files (x86)\Alpari Limited MT4\terminal.exe EXCEPTION_CONTINUE_SEARCH Those messages can be safely filtered.
When I begin DbgView then the settings on the initial dialog are as follows in my dev-computer:
https://www.nigeriaforextrading.com/attachments/1530270825.png
This filters the sound so the debug output gets more meaningful.
I am use auto.arima() for calculates. This function is implemented not correctly some times. Please help me. I have errors even launching terminal. I utilize tester egies maybe it is the cauce of errors. My R :.... Can you post the code such as the function where R_calculates() gets called, please?
Javaloxxasjack
12-14-2022 06:06,
Hey guys, thanks for this wonderful thread. I am just beginning, total noob using mql4, a little more familiar with R. I have a couple questions:
1. After downloading the right files to your new mt4 new version (here: https://github.com/micclly/mt4R), I am now able to compile mt4R.mqh, mt4Test.mq4 and the 2 indiors without difficulty. But when I try to attach the script mt4rTest.mq4 to a chart, this is what DebugView messages. (Perhaps because we are saturday?) I'm worried about the lineup
[2204] Invalid parameter passed to C runtime operate. . If that output is normal Could you please check?
[1576] installed exception handler for C:\Users\ASUS UX32L\AppData\Roaming\MetaQuotes\Terminal\50CA3DFB 510CC5A8F28B48D1BF2A5702\MQL4\Libraries\mt4R.dll
[1576] lt;2gt; Produce: trying to begin R: C:/Program Files/R/R-3.2.1/bin/x64/Rterm.exe --no-save
[2204] Invalid parameter passed to C runtime operate.
[1576] lt;2gt; ExecuteCode: in gt;gt;gt; options(digits=15)
[1576] lt;2gt; ExecuteCode: out lt;lt;lt;
[1576] lt;2gt; Produce: R successfully started
[1576] RInit: RHandle = 6EDF95C (116259164)
[1576] lt;2gt; ExecuteCode: in gt;gt;gt; foo lt;- c(0, 1.25, 2.5, 3.75, 5)
[1576] lt;2gt; ExecuteCode: out lt;lt;lt;
[1576] lt;2gt; ExecuteCode: in gt;gt;gt; baz lt;- foo * 42
[1576] lt;2gt; ExecuteCode: out lt;lt;lt;
[1576] lt;2gt; ExecuteCode: in gt;gt;gt; as.vector(baz)
[1576] lt;2gt; ExecuteCode: out lt;lt;lt; [1] 0.0 52.5 105.0 157.5 210.0
[1576] RDeinit: RHandle = 6EDF95C (116259164)
[1576] lt;2gt; Cease: Quitting R
[1576] lt;2gt; Cease: sending quit()
[1576] lt;-1gt; TPlotEventLoop: terminating
[1576] lt;-1gt; TRConsole: destroying
[1576] removed exception handler for C:\Users\ASUS UX32L\AppData\Roaming\MetaQuotes\Terminal\50CA3DFB 510CC5A8F28B48D1BF2A5702\MQL4\Libraries\mt4R.dll
[5356] SHIMVIEW: ShimInfo(Total )
2. It would be a huge help if you could provide the possible mt4R app that can show me the way exactly mt4R and R communie to me. For example:Every 3 seconds let's say: Send OHLC data to R (closing prices, for example, reversed(?)) Use R to do a simple operation together with the timeseries, say, multiply the last record by two Plot this data into a R window for a second get back these data from R to mt4R Alert the last album (multiplied by two ) 3. In your opinion, what is the best documentation on the market for me?
My purpose is to look the simplest EA that could communie with R, so I would make all my changes in R, not at the EA, as was told earlier in this thread also ). I realize that I ask a lot so the first answer gets 1000 awesomeness points
Javaloxxasjack
12-14-2022 06:17,
Hi again,
I am now running arbomat and trendomat without difficulty. Would continue to be useful to have an illustration of a functioning program sending information to and receiving from R.
Thanks!
javichugf
12-14-2022 06:38,
It may be fascinating migrate this endeavor to MT5.
Anyone has tried to use this dll in MT5? Unfortunately, to attempt it I want an mt4RTest.mq4 programmed in MT5 language and that I don't understand mql5 (yet!)
If anyone understand how to interpret this evaluation script to mql5 could try it?
Due
Hi guys.
I have been trying to conduct Arb-O-Mat together with my MT4 Version: 4 Build: 910, too with R-3.2.2 without a success. If there is a person who give me
a thorough step by step tutorial on how to set up and run Arb-O-Mat like below image. https://www.nigeriaforextrading.com/attachments/1530270826.pnghttps://www.nigeriaforextrading.com/attachments/1530270826.png
https://www.nigeriaforextrading.com/attachments/15302708421378101994.png
obijan68
12-14-2022 07:27,
You're right dear, but unfortunately I am not acquainted with any sort of programming. I am done with these bundles.
But it is still hanging in the mid. Now?
Regards,
https://www.nigeriaforextrading.com/attachments/1530270871415548467.png
https://www.nigeriaforextrading.com/attachments/15302708731298784599.png
bmunamoox
12-14-2022 07:46,
You are right dear, but sadly I am not familiar with any kind of programming. I am done today with these bundles. But it is still hanging at the middle. Now? Best wishes, image image No - it is not hanging and you already mastered quite a lot. On copying the files to the 13, Many users drop out and you also did so perfectly. And by installing the packages you already learned a bit about the package management that's pretty awesome.
It's waiting for a new candle to start (which does not occur on weekends) and attempts to predict on open the indication of the Close-Open return. (Not really very good at this but better than a coin flip anyway)
You'll notice a green ( ) or a red (-) dot in the start of a candle when the forecast is started.
Attempt to Use the R-Sample. Mq4 if you want to find some consequences NOW - or use the weekend for some reading about R https://www.nigeriaforextrading.com/attachments/1530270860.png
obijan68
12-14-2022 07:55,
Due alot its all for you. How can you determine which package is need to be set up?
Regards,
https://www.nigeriaforextrading.com/attachments/1530270875731282505.png
Really intriguing
gotta work on this
anyhow, found latest release bundle here
http://www.mql5.com/en/code/11112
OMG
eventually I did it!!
https://www.nigeriaforextrading.com/attachments/15302708771468459764.png
omiolsolecalvel
12-14-2022 08:20,
OMG finally I did it!! picture is the change you did to the code. Or exactly the same you download from http://www.mql5.com/en/code/11112??
In the event that you made any modifications please place it here. It boost this thread and will be very helpful.
https://www.nigeriaforextrading.com/attachments/1530270863.png
bmunamoox
12-14-2022 08:27,
quote is the change you did into the code. Or the same you download from http://www.mql5.com/en/code/11112?? If you made any modifications please post it here. It will be quite helpful and boost this thread. Https://www.nigeriaforextrading.com/attachments/1530270863.png From the looks it's the version distributed here: https://www.nigeriaforextrading.com/forex-brokers/187-wtf-safe-australia-broker.html
The version out of me has some extensions attracted into the code like OHLC-Copy-all and multiline-R commands.
The version http://www.mql5.com/en/code/11112 is a largely simultaneously done fork of the sourcecode found in the beginning of this thread here to get things running again following the Metaquotes fsckup of MT4.
He uses GIT to get sourcecode versioning and I am using a personal SVN server on a few of my VPS machines.
The usage of GIT makes sense to me to get more programmers into the code and that I actually would love to bring the extensions of mine to his code there. That is exactly what the GPL license is all about, to share knowledge and expertise.
quote is their any change you did into the code. Or the same you download from http://www.mql5.com/en/code/11112?? In case you made any modifications please post it here. It will be quite valuable and boost this thread. Https://www.nigeriaforextrading.com/attachments/1530270863.png I use the sole Naddmer uploaded here
https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/147-simple-mt4-email-notifier.html
the code out of mql4 I Can't get it to work
So today R is working
Any system/egy you guys wanna share? Foundation on utilizing R, of course https://www.nigeriaforextrading.com/attachments/1530270863.png
By the manner
I must go thru manual installation of packages that I downloaded from CRON in zip file.
I will posted here, even if there's anybody similiar to my situation of lack of internet/firewall access.
Packaged to download:FBasics quantmod zoo xts MASS fGarch CRAN R package download link: http://cran.r-project.org/web/packages/available_packages_by_name.html
Once downloaded, start R
from the console do the following
Inserted Code gt; liblt;-c(C:/Program Files/R/R-3.1.0/library) gt; lib Number 91;1#93; C:/Program Files/R/R-3.1.0/library gt; pkglt;-c(C:/xxxxxx/fBasics_3010.86. Zip ) gt; install.packages(pkg,repos=NULL,lib) package #8216;fBasics#8217; successfully unpacked and MD5 sums checked gt; qlt;-c(C:/xxxxxx/quantmod_0.4-0. Zip ) gt; zoolt;-c(C:/xxxxxx/zoo_1.7-11. Zip ) gt; xtslt;-c(C:/xxxxxx/xts_0.9-7. Zip ) gt; masslt;-c(C:/xxxxxx/MASS_7.3-34. Zip ) gt; fgarchlt;-c(C:/xxxxxx/fGarch_3010.82. Zip ) gt; pkgslt;-c(q,zoo,xts,mass,fgarch) gt; install.packages(pkgs,repos=NULL,lib) package #8216;quantmod#8217; successfully unpacked and MD5 sums checked package #8216;zoo#8217; successfully unpacked and MD5 sums checked package #8216;xts#8217; successfully unpacked and MD5 sums checked package #8216;MASS#8217; successfully unpacked and MD5 sums checked package #8216;fGarch#8217; successfully unpacked and MD5 sums checked
bycho2818
12-14-2022 10:00,
Hi Guys,
I got invalid parameter pass into C runtime function mistake. Anyone knows how to fix this? Employing MT670
Thanks in advance
https://www.nigeriaforextrading.com/attachments/15302708841125866513.png
Hi Guys, I got invalid parameter pass to C runtime function mistake. Anybody knows how to solve this? Using MT670 Thanks in advance picture
looks like C runtime evironment was lost to me. I don't know how to fix. Sorry.
jllmogcam3
12-14-2022 10:26,
Hi,
from the indior settings fo R-Sample the Rmethod mle is not working. Watch Debug:
The best way to fix it?
https://www.nigeriaforextrading.com/attachments/1530270889963232733.pnghttps://www.nigeriaforextrading.com/attachments/15302708911652381111.png
bycho2818
12-14-2022 10:46,
MLE is for series. Check if your X is an array rather than matrix
BTW, can I check with you what's ur MT4 variant?
jllmogcam3
12-14-2022 10:54,
Could you describe more in detail, everything you ment. I tried on 610 and Construct 670.
Hi Guys, I obtained invalid parameter pass to C runtime function mistake. Anyone knows how to solve this? Employing MT670 Thanks beforehand picture
I must ask what mt4R package you use.,
I will become just the one here https://www.nigeriaforextrading.com/forex-brokers/87-iamfx-mt4.html
bycho2818
12-14-2022 11:16,
quote I have to ask what mt4R package you use., I will get only the one here https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/234-rainbow-consolidation-ninjatrader.html Thanks. Managed to get it functions
bycho2818
12-14-2022 11:26,
Hi Guys,
Anyone have the onetick script is effective?
Due
Hi Guys, Anyone have the onetick script that works? Thanks ShinjiOno
what would you mean by onetick
The source code should be put by you on github
Mikolomg
12-14-2022 11:54,
==copied== http://codebase.mql4.com/9226 Title: mt4R for new MQL4 Author:http://www.mql4.com/users/micclly (2014.02.06 15:31) Rating:10 Downloaded:366 Download: picture http://codebase.mql4.com/download/41479 (152.0 Kb) picture http://codebase.mql4.com/download/41480 (303 bytes) Description: mt4R, originally developed by Bernd Kreuss and distributed http://www.mql4.com/go?https://sites.google.com/site/prof7bit/r-for-metatrader-4, does... Does it Arb-O-Mat works OK with MT4-600 today?
omiolsolecalvel
12-14-2022 12:04,
Yes its functions. . I don't understand about MT4 600 above. .
regards//
Oxlagwnho
12-14-2022 12:12,
Some shed some light to utilize this indior here.
https://www.nigeriaforextrading.com/trading-discussion/39-charting-software.html
Replacing ZZ here.
https://www.nigeriaforextrading.com/trading-discussion/45-esignal-cqg-vttrader.html
vicpkmsicilay7
12-14-2022 12:20,
Hello,
I am completely new to MQL4 and maybe someone could help me with thisI tried to compile an evaluation EA that should use the R interface. This worked and I could attach it into a chart, but after opening R in a command line window it ceased. The remaining portion of the function wasn't implemented until the command line window manually closed. But the easy improvement in R didn't work and eventually I got a = 0 as output.
The same difficulty arose with arbomat, it ceased after opening R in the command line.
I am using Windows R and 7 3.0.3.
Thank you a lot!
Inserted Code #include lt;mt4R.mqhgt; extern series R_command = C:/Program Files/R/R-3.0.3/bin/i386/R.exe --no-save; extern int R_debuglevel = 1; int rhandle; int init() double temp = 3; rhandle = RInit(R_command, R_debuglevel); RAssignDouble(rhandle, a, temp); RExecute(rhandle, a lt;- a * 2); temp = RGetDouble(rhandle, a); Print(a =, temp); return(0); //-------------------------------------------------------------------- int deinit() RDeinit(rhandle); return(0); //--------------------------------------------------------------------
Mikolomg
12-14-2022 12:26,
Hello all
I've allowed arb-o-mat but charts called from R disapear milisecond once they pop-ed up. Does anyone knows what shall I do to see that the R charts (and deviations onto it). I am able to see just regressors in the moment (look at picture).
Rgs fxj
https://www.nigeriaforextrading.com/attachments/1530270935584205862.png
Hi all, I'm a noob in Programming in trading, I'd Attempted 7-bit code, in win-8 with R-2.11.1, I'd followed According to the guie of hte top Thoughts here, but Discovered me in trouble, I'd Attempted 7-bits 1st snapshot Where he'd shown a Chart with R-graphics, it Functioned with no error, but the Images device does't appear, I'd put the path as D:\R-2.11.1\bin//Rterm.exe --no-save, but Tough Fortune, and Something Else, I could not figure out the Debugview output it gives bizzare output like
00000001 0.00000000 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000002 0.10889539 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000003 5.20380497 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000004 5.31265783 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000005 5.45372057 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000006 5.56265259 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000007 10.21999454 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000008 10.32897186 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000009 10.90760231 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000010 11.01651955 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000011 15.23648262 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000012 15.34537697 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000013 16.36150360 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000014 16.47058105 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
00000015 20.25278282 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - Scheduled
00000016 20.36177444 STORMINI: StorAHCI - LPM: Port 00 - transit into Slumber from Partial - bailed out, current link state Isn't Partial: 1
What is the Problem,if any1 have time please guide me from the.
Regards
ASHIS
Hi ,
First Article! I am interested in utilizing predictive modeling capabilities in R for trading.
Does anyone use this integration for real-live trading? I am concerned about basing a trading platform on an supported plug such as this one in which others have reported issues.
Specifically, my requirement is to
1) Metatrader To R: Duplicate OHLC bar info (current bar plus a couple hundred of the latest bars) in the trading platform (metatrader in this instance ) to R
two ) R to Metatrader: Duplicate a buy/sell sign straight from R to metatrader.
Could someone possibly verify whether the above functionality is working in the current variant of the integration?
I have read that people are having issues with the machine when displaying R graphics but I don't care about that. Is your two requirements that are above.
Lunelagoma
12-14-2022 12:48,
Hi All,
I'm experiencing some difficulty trying to function with mt4R.dll. I have followed all instructions and at the tester freezes with no error outputted. I'm using MT4 build 646.
One other thing I think is strange is that the Rterm doesn't seem to begin but the path to Rterm.exe is right in my EA.
Thanks in advance for your input on my issue.
Greatest Speeches
Lunelagoma
12-14-2022 12:58,
Hi All, I am experiencing some trouble trying to work with mt4R.dll. I have followed all instructions and in the tester freezes with no error outputted. I am using MT4 build 646. One additional thing I think is strange is that the Rterm does not seem to begin but the route to Rterm.exe is correct in my EA. Thanks for your input . Greatest Speeches It occurs I really had a wrong route to R. I was able to detect it using the wonderful debug program suggested by the developer.
All the best!
Bammenga
12-14-2022 13:06,
Some repairs (had some obscure crashes) - and another example of the multiline inline code (function declaration). Additionally, I eliminated the eventhandler.mqh since there is a onBar() eventhandler in MQL4 now. Might have to see how it works out. And just for the kisses there is now a function declaration inside the init() which is employed in the onBar() procedure of the indior resp in the doRDraw() procedure which is called out of here. // // Get the packages announce and needed // a purpose too. RExecute(R, pkgs lt;- c('quantmod') CR lapply(pkgs,... Cool and fantastic work, Naddmer!
I invested quite sometime on the R end to optimize my egy and I am close to the end of the testing, and was about to select between Jave API with R interface or merely use MT4 with connected with your new multi-command mt4R, your upgrade will save lot of time to run the forward-test beneath mt4. I will report you back after my algo gets steady. Many thanks!
Mikolomg
12-14-2022 13:12,
quote It happens I really needed a incorrect path to R. I managed to detect it with the wonderful debug program suggested by the developer. All the best! The only issue were incorrect path? I have had set up until MT4 has not updraded to version lt;600 and stopped working. While I reset on new MT4 600 all system been down and I dont know why.
Will you inform me how can you figure out how to install. Many thanks!
bmunamoox
12-14-2022 13:21,
quote The only issue were wrong path? I have had set up till MT4 has not updraded to model lt;and 600 stopped functioning. While I reset on new MT4 600 all system been down and I dont know why. Are you going to inform me how did you manage to set up. Many thanks! The course is definitely not the only culprit since Construct 600 of MT4.
The modifications which were performed from the internals of all MT4 were this grave that any well operating software company would have spared them to get a major UPGRADE rather for a minor UPDATE.
I left some modifiions into the Lazarus code so that the indiors and samples would operate again.
Here is the archive containing them:
https://www.nigeriaforextrading.com/attachments/15302709371953202831.3-ohlc-multicommand-2014-09-05
Inserted Code Archive: mt4r-1.3-ohlc-multicommand-2014-09-05.zip Length Date Time Name --------- ---------- ----- -- 164 2014-06-25 22:05 MT4-R/mt4R_source-1.3.0.25/copy_mt4r.bat 18092 2013-08-02 20:36 MT4-R/mt4R_source-1.3.0.25/gpl-2.0.txt 240640 2014-05-03 11:27 MT4-R/mt4R_source-1.3.0.25/mt4R.dll 5116 2014-04-29 19:29 MT4-R/mt4R_source-1.3.0.25/mt4r.lpi 9104 2014-02-10 18:12 MT4-R/mt4R_source-1.3.0.25/mt4r.lpr 808 2014-03-09 16:57 MT4-R/mt4R_source-1.3.0.25/mt4r.res 29046 2014-05-03 11:27 MT4-R/mt4R_source-1.3.0.25/profs_trconsole. pas 4121 2013-08-02 20:36 MT4-R/mt4R_source-1.3.0.25/profs_win32exceptiontrap. pas 12772 2014-02-14 00:32 MQL4/Include/mt4R. mqh 64077 2014-06-25 22:04 MQL4/Include/common_functions.mqh 3431 2014-02-10 18:15 MQL4/Include/eventhandler. mqh 240640 2014-05-03 11:27 MQL4/Libraries/mt4R.dll 6964 2014-06-25 22:04 MQL4/Indiors/R-Sample. mq4 7062 2014-04-17 08:28 MQL4/Indiors/R-CandlePrediction. mq4 16821 2014-04-29 19:29 MQL4/Experts/R-##-Arbomat.mq4 2990 2014-05-03 13:40 MQL4/Experts/R-##-Covariance.mq4 15386 2014-05-11 23:06 MQL4/Experts/R-##-Trendomat.mq4 579 2014-02-10 18:15 MQL4/Scripts/onetick. mq4
obijan68
12-14-2022 13:29,
Hello! Naddmer,
I have placed your documents in my MT4 and connected Indiors using the chart. But I can not see anything on my chart, can please tell me is it working?
I have also installed R in specified path (Image Attached).
https://www.nigeriaforextrading.com/attachments/153027094088768095.png
https://www.nigeriaforextrading.com/attachments/1530270942175699926.png
bmunamoox
12-14-2022 14:08,
Hello! , I have placed your documents in my MT4 and connected Indiors with the chart. But I can't see anything in my chart, can please tell me is it? I also have installed R in designated course (Image Attached). picture picture From what I could see, there is a malfunction - however you figured out this one too:--RRB-
Now here is a fast step by step to analyze the reason for it.Eliminate all R based indiors and EAs from all charts. Start DbgView.exe.
If you haven't downloaded this tool you can do this here: http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx Set the filter in accordance with that screen shot:
https://www.nigeriaforextrading.com/attachments/1530270915.png Now set an R based indior onto one chart and look onto the messages of this DbgView window. On a functioning installation the Debugoutput looks like this:
https://www.nigeriaforextrading.com/attachments/1530270944920736087.png On a new installment of R likely the essential R packages are missing. Be aware of messages at the DbgView output under of this lapply(pkgs, require,...) call and set up the missing packages from the R command line
( e.g.: install.packages(quantmod) ).
obijan68
12-14-2022 14:35,
Thanks Naddmer!
I did exactly the same and I have found the issue (Image Attached). I have downloaded the package that was missing, but do not understand how to solve it. Now what should I do?
Regards,
Que.
https://www.nigeriaforextrading.com/attachments/1530270946485252751.png
https://www.nigeriaforextrading.com/attachments/1530270948729195626.png
bmunamoox
12-14-2022 14:42,
Thanks ! I did the exact same and I've discovered the issue (Image Attached). I have downloaded the missing package, but do not know how to fix it. Now what should I do? Que, regards. picture picture Thanks for the screen output of your installation. Sadly the lines directly below the lapply(...) call are missing there.
The failed as.xts results from a failed initialization of this quantmod package in R.
should you really do an install.packages(quantmod) then all dependencies for your R-Sample. Mq4 is going to be pulled from the download server of R.
(e.g. xts and zoo)
Additionally you are using R 3.1.1 - I'm currently in the progress of downloading this variation to check out whether there are some more problems.
obijan68
12-14-2022 14:58,
1 Attachment(S ) ) Due Dear,
Yes! ) I can see in the MQL file where it is calling AS.XTS. Please also indie where to copy the (quantmod)? From anyother place or the Folder?
https://www.nigeriaforextrading.com/attachments/1530270951749178476.png
bmunamoox
12-14-2022 15:19,
Thanks Dear, Yes! I can view in the MQL file where it's calling AS.XTS. Please also indie where to copy the (quantmod)? From anyother location or the R Folder? picture Ah - allright - I see.
There's nothing to copy, just open R and after that you are going to get a command line interface to R.
Enter the command
install.packages(quantmod)
into this command line window, then pick your closest download mirror and let R do another part. Https://www.nigeriaforextrading.com/attachments/1530270920.png
https://www.nigeriaforextrading.com/attachments/15302709521301932006.png
Edit: Lately I'm done upgrading R from 3.0.3 to 3.1.1 - this is how it looks like:Messages from DbgView when starting R-Sample. Mq4:
https://www.nigeriaforextrading.com/attachments/1530270954912799039.png
Notice how the use of the quantmod bundle also automatically requires the use of both xts and zoo. Chart where the R-Sample. Mq4 is operating:
https://www.nigeriaforextrading.com/attachments/15302709561911502865.png
obijan68
12-14-2022 16:32,
O! My God, that one is your http://dictionary.reference.com/browse/difficultiesomplied indior in my years forex life. Again! Please identify.
https://www.nigeriaforextrading.com/attachments/1530270958584383435.png
bmunamoox
12-14-2022 17:29,
O! My God, this one is your http://dictionary.reference.com/browse/difficultiesomplied indior within my years Foreign Exchange life. Again! Please identify. picture R is a full blown mathematical oriented programming language with a very steep learning curve.
If you learn that - you will master anything. Promised! :--RRB-
From what I could see you are using the R-Candleprediction. Mq4 indior instead of the R-Sample. mq4.
The require-List of this Indior is at least the fGarch package which you need to install by inputting
install.packages(fGarch)
to the R console .
Best practise is to install every package which is in the
pkgs lt;- c('zoo',''xts',''fBasics',''MASS',''quantmod',''fG arch') CR
lineup to prevent any additional errors in the exact same class.
Also the filter settings in the DbgView.exe are probably mistyped as there are a lot of EXCEPTION_CONTINUE_SEARCH messages tainting the log output and reducing the readability.
I deinstalled two bundles in my setup to get you some output which is in the DbgView log when R demands are not met:
https://www.nigeriaforextrading.com/attachments/1530270960256686591.png
Bammenga
12-14-2022 17:47,
It works! Thank you, FXEZ.
I will try my versions and report back to the thread later.
, See the attached document. I simplified it a little - with the easy(ier) interface instead of the original interface. Since you can not guarantee that MT4 will execute as you think it should I try to stay away from RExecuteAsync. As a result I restricted updating in the beginning () function to once per pub to cut down on wasted processing period. All this EA does is print three numbers out, but at least you ought to be able to get some feedback there. Also see the factor to toggle save / no save for your picture and a file path. Notice the arrangement...
Bammenga
12-14-2022 18:02,
Inserted Code #property copyright ? Bernd Kreuss #include lt;mt4R.mqhgt; #include lt;common_functions. Mqhgt; extern int back = 500; extern int order = 200; extern int ahead = 20; extern string R_command = C:/R/R-3.0.1/bin/i386/Rterm.exe --no-save; extern int R_debuglevel = two; extern bool saveImage = false; extern string saveDir = C:/R/; extern int delta_L=30; extern int delta_S=30; extern double TakeProfit = 70; extern double StopLoss = 35; extern double Lots = 0.1; extern double Poin; //int rhandle = 0; datetime thistime; int init() StartR(R_command, R_debuglevel); should (Stage == 0.00001) Poin = 0.0001; //6 digits Points fix else if (Stage == 0.001) Poin = 0.01; //3 digits Points fix(for Yen based pairs) else Poin = Stage; //Normal // set thistime into a arbitrary init value so the start function will operate the first-time thistime = Time#91;5#93;; return(0); int deinit() if (UninitializeReason() ! = REASON_CHARTCHANGE) StopR(); return(0); int begin () if (thistime == Time#91;0#93;-RRB- return(-1); // only update once per pub double histNumber 91;#93;; double pred#91;#93;; double buf_prediction#91;#93;; int I,ticket; // if(Volume#91;0#93;gt;1) return; //1 pub one order if(AccountFreeMargin()lt;(1000*Lots)) Print(We Don't Have Any cash. Free Margin =, AccountFreeMargin()); return(0); //cash check ArrayResize(hist, back); for (I=0; ilt;back; I ) hist = Close; //fill up the hist range with Close price Rv(hist, hist); Rx(hist lt;- rev(hist)); //get into the Ideal order punctually Ri(ord, order); Rx(version lt;- ar(hist, aic=FALSE, order=ord, method='ols')); //build the ols model if (Rgi(as.integer(exists('version'))) == 1) // if there is a version (the factor is defined ). Ri(ahead, ahead); Rx(pred lt;- predict(model, n.ahead=ahead)$pred); // when There's a version, forecast a ahead value beforehand ArrayResize(pred, ahead); Rgv(rev(pred), pred); // Open Buy_Order if((predNumber 91;0#93;-Open#91;0#93;)gt;delta_L*Point) //gap bigger than Long threshold ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Stage,Ask TakeProfit*Point,busted,0,Green); // execution when (ticketgt;0) if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print(BUY order started:,OrderOpenPrice()); else Print(Error opening BUY order:,GetLastError()); return(0); // exit // Open Sell_Order if((Open#91;0#93;-pred#91;0#93;)gt;delta_S*Point) ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid StopLoss*Point,Bid-TakeProfit,0 Stage,busted,0,Red); // execution when (ticketgt;0) if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Printing (SELL order started:,OrderOpenPrice()); else Print(Error opening SELL order:,GetLastError()); return(0); // exit if (saveImage) Rx(save.image( saveDir .RData)); thistime = Time#91;0#93;; return(0);
As a Fast proof of concept (so do not use on LIVE account), the above EA reads MT4 Close info in an array in R and forecast a value using ols version, and returns back to MT4 for order launching. It was able to open ~500 order in 6 hours and busted half of a demo account.
FXEZ, why do you put thistime = Timing [5];, not Time[0]?
P3mc3v4l
12-14-2022 18:19,
Be aware that the very first line in the start() function has a condition with the thistime factor that exits (return) if Time[0] == thistime.
The initialization init() has as its purpose initializing the thistime factor to some value other than Time[0] to ensure start() can run all the way through without exiting on the first line, on the very first load of this EA. I hope that makes sense.
Bammenga
12-14-2022 18:39,
Hi fellas https://www.nigeriaforextrading.com/attachments/1530270978.png initially a big thank to 7bit for sharing his sourcecode of the API. Valuable in many respects. We all owe him one. I had some needs have executed it here and to have multicommand support in this API. Now it is possible to send more than one command to R from the API: RExecute(R.ProcHandle, d lt;- head(tail(hist_r, sampleCount pOffs), sampleCount - pOffs 2) LineEnding d lt;- as.xts(d, order.by=as.POSIXct(d[['Timestamp']], source ='1970-01-01 00:00', tz='UTC')) LineEnding // z lt;- mind (zoo(d[,2:6]), sampleCount)... Good work, Naddmer.
So can I send several R commmands in parallel with your new plugin today? Or maybe I could still use 7bit's old version and put a Rx(source(command.R)) for batch style? Thanks.
Bammenga
12-14-2022 18:54,
Note that the first line in the beginning () function includes a condition using the thistime factor that exits (return) if Time[0] == thistime. The initialization init() has as its purpose initializing the thistime factor to some value aside from Time[0] so that beginning () can run all of the way through without departing the first line, on the first load of this EA. I hope that makes sense. Thank you, EZFX. I will test it out myself, testing is all about studying. :-)
bmunamoox
12-14-2022 19:10,
quote Great work,. So can I send R commmands in parallel with your new plugin? Or maybe I can still utilize 7bit's old version and put a Rx(origin (command.R)) for batch style? Thanks. Hello Croupier,
you can - of course - still utilize the origin () function of R to run multiline R commands. With this expansion this could have been the only means to run multiline commands (e.g. control structures). The old API suspended the R-process once you attempted to accomplish this as it had been waiting for a new prompt line that never came.
This is a backwards compatible extension to the API which implements:
* Multiline support for RExecute()
* Duplicate a batch of OHLC-values from Metatrader to R and also avoid the fairly slow loop in MQL using RAssignOHLC().
You said that the eventhandler.mqh was lost: I forgot to post this. Here they are.
Note that this edition of R-Sample makes complete use of the multiline-support as well as of the RAssignOHLC() feature.
The R prediction code is combined together in the init() procedure of the indior here:
Inserted Code // That is the control cluster which calculates the predictions PREDICTION_COMMAND= data lt;- head(tail(hist_r, samples retro)( samples) CR z lt;- sighting (data#91;,2:6#93;, order.by=as.POSIXct(information $Timestamp, origin='1970-01-01 00:00', tz='UTC')) CR if (priceModel==PM_OPEN) hist lt;- z$Open CR if (priceModel==PM_HIGH) hist lt;- z$High CR if (priceModel==PM_LOW) hist lt;- z$Low CR if (priceModel==PM_CLOSE) hist lt;- z$Close CR if (priceModel==PM_TYPICAL) hist lt;- (z$High z$Low z$Close) / 3 CR if (priceModel==PM_MEDIAN) hist lt;- (z$High z$Low) / 2 CR if (priceModel==PM_WEIGHTED) hist lt;- (z$High z$Low 2*z$Close) / 4 CR h lt;- as.xts(hist) CR version lt;- ar(h, aic=FALSE, order=ord, method=' Rmethod ') CR p lt;- predict(model, n.ahead=beforehand ) CR pred lt;- de $pred CR ub lt;- last(z$Close) p$se CR lb lt;- last(z$Close) - p$se;
... and the whole command cluster is passed to R to get the job done :
Inserted Code int cnt=ArrayCopyRates(hist_r, NULL, 0); while (GetLastError()==4066) Printing (init: ArrayCopyRates barfed... retrying); Sleep(1000); cnt=ArrayCopyRates(hist_r, NULL, 0); log(doRDraw: Utilities =, DoubleToStr( iBars(NULL,0), 0), vs. cnt=, DoubleToStr(cnt, 0) ); // Prepare the data for the indior... RAssignOHLC(R, hist_r, hist_r, iBars(NULL,0)); // Do the calculations... RExecute(R, PREDICTION_COMMAND); RGetVector(R, pred, pred, beforehand ); RGetVector(R, ub, ub, beforehand ); RGetVector(R, lb, lb, forward );
Note that the matrix hist_r contains the whole bunch of MT4 candles available from the background!
Otherwise: Use the source, Luke and forgive me my bad English. English from Yoda I've learned https://www.nigeriaforextrading.com/attachments/1530270978.png
https://www.nigeriaforextrading.com/attachments/15302709861605197896.zip
Bammenga
12-14-2022 20:07,
Thank you Naddmer for your excuse and the sample code!
I was testing some system tonight with source() to load few purposes, apparently I didn't get everything right because it didn't print out the signal from the log window, even though you mentioned it should be OK even with 7bit's old version API. I was about to split down the function into a list of extended command-lines and came straight back to this thread to test in case you've posted some answers yes you did,:--RRB-
Your extension should be a nice alternate to test for multi-command in batch mode, copying OHLC-values over is not really an issue using ArrayCopyRates on your code and then convert to xts, but your multi-commands API should be otherwise quite useful in coping with big trunk of code for serious R participant. https://www.nigeriaforextrading.com/attachments/1530270978.png
Hi guys!! I´m very very fresh here...
First of allTHANKS A LOT with this 7bit!!! This ´s gr8!
That I ´m a Brazilian Biostatistician and trying to input in forex market. I´m working with the MT4/R interface (gr8 job again!) ...
So, I´m trying to load a R WORKSPACE by Metatrader, such as:
RExecute(rhandle, load(\C:\\Users\\Marcio\\Records \\SOBE-DESCE (60)\));
Is that possible?? Why my script STOP (frezzen)??
Tks for advance!
Marcio
Bammenga
12-14-2022 20:44,
Just a fast awake, the new mt4 build600 seems to have changed the documents arrangement and added few items which make the old mt4r plugin fail to load, at least it is true to get ironfx.com's new mt4 client. After so almost 4 years since the launch, this brilliant addon really need some upgrade.
Cheers
Picamo48
12-14-2022 20:51,
Http://codebase.mql4.com/9226
Name: mt4R for new MQL4
Writer:
http://www.mql4.com/users/micclly (2014.02.06 15:31)
Description:
mt4R, originally developed by 7bit and dispersed http://www.mql4.com/go?https://sites.google.com/site/prof7bit/r-for-metatrader-4, doesn't work correctly with new MQL4.
That I modiifed the dll and the include file to support new MQL4.
Mikolomg
12-14-2022 20:59,
http://codebase.mql4.com/9226 Title: mt4R for new MQL4 Author: http://www.mql4.com/users/micclly (2014.02.06 15:31) Description: mt4R, initially developed by 7bit and dispersed http://www.mql4.com/go?https://sites.google.com/site/prof7bit/r-for-metatrader-4, does not operate properly with new MQL4. I modiifed the and that the dll include file to support new MQL4. Whats the issue with older one? Does it create regressors that are wrong?
bmunamoox
12-14-2022 21:07,
Seems like MetaQuotes had the idea to switch the file system structure.
This is an action one would expect through a major update (MQL4 - MQL5) but maybe not on a minor upgrade.
Along with that they've removed the live update feature about a year ago - so you are not able to choose to upgrade your live environment after all tests passed during the updated testing atmosphere. This way you are made to betatest their code onto your actual live money accounts.
This is not what I call best practise.
I've some other expressions for that.
Many of them may incorporate the words braindead and boneheaded.
Some other modifications were the usage of unicode strings rather than ansi strings.
Croupier: I'll have a look to the function declaration question you've posted. Seems pretty interesting that R has a distinct prompt there too.
bmunamoox
12-14-2022 21:18,
Some more hassles: They've changed the data structure of RateData as shown below rather than introducing a second structure which includes the elongated information.
From O/L/H/C to O/H/L/C
They all of a sudded different on TickVolume and TradeVolume and introduced Spread - whatever Spread means to a candle based data representation (Average Spread? Median Spread? Last Spread? First Spread? Some randomly selected Spread?)
https://www.nigeriaforextrading.com/attachments/1530270988125342583.png
bmunamoox
12-14-2022 21:39,
This Construct should restore the old performance on MT4-Build 600 based installations. (embedded multiline R-code, Bulk-OHLC-Transfers to R)
It creates no test for any MT4 Construct currently as there isn't any native function to query with the build number.
If you'd be so kind and report any difficulties with this version I'd be most thankful.
@croupier: I will take a look to the function declaration thing .
https://www.nigeriaforextrading.com/attachments/15302709901105519796.30
Julay3119
12-14-2022 21:58,
It makes no test for any MT4 Build currently as there's not any native function to question the build number. Builds 600 do possess such a role: TerminalInfoInteger(TERMINAL_BUILD)
Also, regarding the volumes: in Currency Market there's the tick quantity, there's no real quantity; otoh, on (stock) exchanges there's real quantity in a stock. Spread is not associated with bid-ask difference.
bmunamoox
12-14-2022 22:07,
quote Builds 600 do possess this kind of function: TerminalInfoInteger(TERMINAL_BUILD) Also, regarding the volumes: in forex there's the tick quantity, there's no real quantity; otoh, on (inventory ) exchanges there's actual quantity in a stock. Spread is not associated with bid-ask difference. Why! What! Thank you very much.
This let me from the problem distributing a DLL which generates crashes on any buildlt;600
As of current the documentation docs.mql4.com doesn't know anything about this function in the chapter customer terminal.
Https://www.nigeriaforextrading.com/attachments/15302709931784156451.png
I'll disperse the next version with the request croupier to announce functions inline also. Just got back from sports and I feel somewhat slacked and hacked and wasted.
The tick quantity is suspicious at best. And the quantity in addition to market depth - at least in FXCM - is available to Plus-Accounts only.
Accounts that have a first equitygt;25kUSD.
Tomorrow will yet another 100 years start. That is for sure.
Thank you very much again.
bmunamoox
12-14-2022 22:22,
Some repairs (had any vague crashes) - and yet another example of this multiline inline code (function statement ).
I also removed the eventhandler.mqh since there is a onBar() eventhandler in MQL4 now. Might have to see how it works out.
And just for the kicks there is presently a function declaration inside the init() which is employed from the onBar() procedure of this indior resp from the doRDraw() procedure which is called from here.
Inserted Code // // Prepare the packages needed and announce // a function too. RExecute(R, pkgs lt;- c('quantmod') CR lapply(pkgs, need, character.only=T) CR getHist lt;- function(z) CR if (priceModel==PM_OPEN) h lt;- z$Broad CR if (priceModel==PM_HIGH) h lt;- z$High CR if (priceModel==PM_LOW) h lt;- z$Low CR if (priceModel==PM_CLOSE) h lt;- z$Close CR if (priceModel==PM_TYPICAL) h lt;- (z$High z$PM_TYPICAL z$Close) / 3 CR if (priceModel==PM_MEDIAN) h lt;- (z$High z$Low) / 2 CR if (priceModel==PM_WEIGHTED) h lt;- (z$High z$Low 2*z$Close) / 4 CR yield (h) CR );
The DbgView look of the groundwork of this function call in addition to its first call is pictured below.
Https://www.nigeriaforextrading.com/attachments/1530270995288355676.png
As one can see there is the function declaration of a role getHist which returns the specified data.frame to the variable hist_r.
I'm not too intimate with that WideString/String/AnsiString/Utf8String of Lazarus as yet. String and pChar was fine for me now.
I might well overlooked some nies. So I'd be thankful if you pointed them out.
https://www.nigeriaforextrading.com/attachments/15302709971041278830.30
bmunamoox
12-14-2022 23:02,
the code previously produced the H1 chart of the ASX200 pictured below.
The vertical line was placed in manually.
https://www.nigeriaforextrading.com/attachments/15302710001787956655.png
omiolsolecalvel
12-14-2022 23:20,
==reproduced ==
http://codebase.mql4.com/9226
Title:
mt4R for new MQL4
Writer:http://www.mql4.com/users/micclly (2014.02.06 15:31)
Rating:10
Downloaded:366
Download:
http://i.mql4.com/ico/zip.gif http://codebase.mql4.com/download/41479 (152.0 Kb)
http://i.mql4.com/ico/txt.gif http://codebase.mql4.com/download/41480 (303 bytes)
Description:
mt4R, initially developed by Bernd Kreuss and dispersed http://www.mql4.com/go?https://sites.google.com/site/prof7bit/r-for-metatrader-4, doesn't work correctly with new MQL4.
I modiifed the dll and the include file to encourage new MQL4.
Latest version:
You can find the latest version from http://www.mql4.com/go?https://github.com/micclly/mt4R/releases. (Because of update time lag by moderation, the attached binary might be older than the latest release at GitHub )
Changelog is additionally at http://www.mql4.com/go?https://github.com/micclly/mt4R/blob/new_mql4_support/CHANGES.md and http://www.mql4.com/go?https://github.com/micclly/mt4R/commits/new_mql4_support.
Update background:
Feburary 10, 2014: v1.4.0-b7: Additional sample experts: Arb-O-Mat and Trend-O-Mat(GitHubhttp://www.mql4.com/go?https://github.com/micclly/mt4R/issues/5).
Feburary 9, 2014: v1.4.0-b6: Fixed the bug of RGetBool/RGetInteger(Githubhttp://www.mql4.com/go?https://github.com/micclly/mt4R/issues/4).
Feburary 9, 2014: v1.4.0-b5: Fixed the bug of RAssignString(Githubhttp://www.mql4.com/go?https://github.com/micclly/mt4R/issues/3).
Feburary 9, 2014: v1.4.0-b4: Fixed the bug of RAssignStringVector(GitHubhttp://www.mql4.com/go?https://github.com/micclly/mt4R/issues/1), also upgraded the small version number in DLL hardcoded.
Feburary 7, 2014: v1.4.0-b1: Altered MQL file encoding to UTF-16
Feburary 6, 2014: v1.4.0-b0: First snpashot
Source:
Source codes are dispersed in a http://www.mql4.com/go?https://github.com/micclly/mt4R/tree/new_mql4_support.
Note:Testing is not enough I had only confirmed that it seems work great with R-3.0.2 on Windows 2012 R2. Performance may be marginally worse, because string in disagreements is always transformed to string that is ansi.
Bammenga
12-14-2022 23:29,
FXEZ, thanks.
This is what I set for Trend-O-mat,
-------
#define RPATH C:/Program Files/R/R-2.15.2/bin/i386/Rterm.exe --no-save
#define RDEBUG 1
#define SNAPSHOTS D:/plots/
#include lt;mt4R.mqhgt;
#include lt;common_functions. Mqhgt;
--------
the error log material in MT4: trendomat USDJPY,H4: Version mismatch mt4R.dll: expected version 1.4 - found dll version 1.3, I appear to hesitate to just reproduce what's been posted as demo, is there really a variant 1.4 mt4R.dll?
I figure I am on the help desk today...
Croupier, visit this post
https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/104-money-management-egy.html
then scroll to post #9 and determine if any of this gives you a few ideas to fix your problems.
FYI IIRC I don't think that it works with 64 bit in MT4. Use 32 bit R using 32 bit MT4
P3mc3v4l
12-14-2022 23:37,
Thanks,.
Here is what I set for Trend-O-mat,
-------
#define RPATH C:/Program Files/R/R-2.15.2/bin/i386/Rterm.exe --no-save
#define RDEBUG 1
#define SNAPSHOTS D:/plots/
#include lt;mt4R.mqhgt;
#include lt;common_functions. Mqhgt;
--------
the error log material from MT4: trendomat USDJPY,H4: Model mismatch mt4R.dll: anticipated version 1.4 - discovered dll version 1.3, I seem to hesitate to just reproduce what has been posted as demo, is there really a variant 1.4 mt4R.dll? Two choices:
1) Re-download the documents from the website simply to make certain that you're all on precisely the exact same version in the event that you got them from the first post.
2) Edit the version number in MT4R.mqh. It states: Inserted Code #define MT4R_VERSION_MINOR 3 // must change to 4 However I've not had a problem using it with version 3.
Bammenga
12-14-2022 23:48,
I did and it seems promising at least the code in post#8 functioned well and plotted a Red color trend-line around the bars curve, but no luck with the rest 2 EAs. It is good enough and I will play with the RExecute(R, pred lt;- predict(model, n.ahead=beforehand )$pred);, 7bit used AR with ordinary least square method, you will find lot more models to test.
Two choices:
1) Re-download the files in the website simply to be certain you're all on precisely the exact same version if you got them in the very first article.
2) Edit the model number in MT4R.mqh. I've not had a problem using it with version 3 although it says: Inserted Code #define MT4R_VERSION_MINOR 3 / 4 must be changed to by /.
cmislisuans
12-14-2022 23:56,
Does this tool require a 4 digit broker? I don't find this in almost any instruction set although I visit a post saying this. Is can or 4 digit a necessity I use a 5 digit broker. The main reason I ask is that I keep receiving the error:
[2948] exception 80000003 at 017003E2 in C:\Program Files\MetaTrader 4a\terminal.exe EXCEPTION_CONTINUE_SEARCH
[2948] exception 80000003 at 017003E2 in C:\Program Files\MetaTrader 4a\terminal.exe EXCEPTION_CONTINUE_SEARCH
I have R installed in - C:\R\R-2.15.2\bin
and the EA is pointing to - #define RPATH C:/R/R-2.15.2/bin/i386/Rterm.exe --no-save
I am running windows vista, sp2. (maybe I need to go to XP? ) )
Any troubleshooting help will be appreciated...
Bammenga
12-15-2022 00:02,
I read somewhere it works in Win7, however I don't know whether your error are 4 digit broker associated.
Does this tool need a 4 digit broker? I see a post stating this but I don't see this in any instruction set. Is may or 4 digit a necessity I use a 5 digit broker. The reason I ask is that I keep getting the error:
[2948] exception 80000003 at 017003E2 in Chttps://www.nigeriaforextrading.com/attachments/1530271016.pngrogram FilesMetaTrader 4aterminal.exe EXCEPTION_CONTINUE_SEARCH
[2948] exception 80000003 at 017003E2 in Chttps://www.nigeriaforextrading.com/attachments/1530271016.pngrogram FilesMetaTrader 4aterminal.exe EXCEPTION_CONTINUE_SEARCH
I have R installed in - C:RR-2.15.2bin
along with the EA is pointing to - #define RPATH C:/R/R-2.15.2/bin/i386/Rterm.exe...
cmislisuans
12-15-2022 00:56,
croupier.... Can you tell me the installation you are using (os/version of R....)? ) I'll build a vitual machine to match and see if I can get it to function correctly.
Bammenga
12-15-2022 01:05,
Mt4 Alpari UK, winXP, and R Bundle and R Port Variations as per the suggestion of FXEZ.
.... Can you tell me that the setup you're using (os/version of R....)? I'll construct a vitual machine to match and determine if I can get it to function.
Thanks 7bit! Can not seem to get the AutoregressionBack indior to operate, run it get RExecuteAsync and RIsBusy Function is not defined. I'd Put the mt4R-1.3.0.25 dll from the experts/libraries directory, place the mqh file from the experts/include directory. Install'R-2.11.1 into'C:/Programme/R/R-2.11.1/bin/Rterm.exe All operate in the IBFX-AU 4.00 Build 432. XP sp3 in Mac os 10.7.3 VMware 3.1.2,will you assist me?
P3mc3v4l
12-15-2022 01:26,
For those guys having trouble with the first run of arbomat, the main difficulties installing come from:
Common Fixes
Read the documentation inside mt4R.mqh and follow the directions.
Read the documentation inside arbomat.mq4 and follow the directions.
If you still can't get it working after reading the above, then try the next:
R problems
R is not installed.
Not altering RTerm.exe (inside arbomat) into a valid path on your computer with forward slashes rather than the typical back slashes, or deleting the --no-save at the end of the path.
Mine is (I found that contrary to what is posted, even the 64 bit version works with MT4 and Win7):
#define RPATH C:/Program Files/R/R-2.14.0/bin/x64/Rterm.exe --no-save
#define RPATH C:/Program Files/R/R-2.14.0/bin/i386/Rterm.exe --no-save
MT4 Problems
Not enabling the EA to allow DLLs (test box) in EA properties or to let live trading (test box) both under Frequent tab
Not installing an essential R package that you would like to reference (I don't think you will find any for arbomat)
Pros not allowed in MT4. (see picture )
Not placing .mqh files in appropriate places. . The directory is gone under by mqh files. You require mt4R.mqh and common_functions. Mqh out of 7Bit's website.
Not placing arbomat in the right location. Place arbomat under specialists / directory (arbomat is an EA maybe not an indior).
Https://www.nigeriaforextrading.com/attachments/1530271016.png
Version Problems
Using out of date dll or mql/mqh documents. (Get latest edition of arbomat, mt4r, from 7Bit's site, not those listed here on FF).
Essential questions to find the root cause of your mistake:
What does it say when you join EA under Pros tab in MT4?
What exactly does DebugView say when you join EA?
Otherwise try the primary thread's key articles:
https://www.nigeriaforextrading.com/trading-discussion/75-eur-jpy.html
https://www.nigeriaforextrading.com/trading-discussion/54-outcome-happened.html
https://www.nigeriaforextrading.com/bitcoin-talk-and-cryptocurrencies/262-spread-cost.html
There may be other people (if so go through the entire thread) but it usually is misspelling a link or forgetting to allow something in MT4. (user error)
julius72
12-15-2022 01:57,
I joined in with this thread. FYI R version 2.11.1 is a secure build with the current mixture on win xp 32 bit. Anything above that didn't work for me as the debugview kept throwing exceptions.
The path is all BACKslashes. Not forward.
Just FYI. . .Thanks.
Issi2004
12-15-2022 02:30,
No luck for me the example on post # 8 doesn't work and I think everything was checked by me. Primarily I'd the latest R version 3 but I watched the last post and installation 2.11.1. It did portion draw a red line at the front of the chart that R 3.0 did not do but the exceptions keep on coming from debugview even if the indior is removed from the chart. I must shut MT4 down to halt the output. I shall have to keep on looking. The post is wrong.
Issi2004
12-15-2022 02:38,
Well it appears the exception is generated frequently along with the indior works using R version 3.0. I would not know anything about the exception message that occurs on each loop of the 23,, if I did not have debugview. Now to get on with using the R messaging within my own MT4 undertaking.
Oh the penny just dropped. It is MT4 that is causing the exception and nothing related to R. By extending the debugview window it says at the end of the line
terminal.exe EXCEPTION_CONTINUE_SEARCH
The strange thing is that I did not notice this occurring the first time that I ran debugview with MT4 but it doesn't indicate it was not there and it's always there now no matter R or indiors used. MT4 is naff to start with people would not be messing around with R I guess although A constant load on the windows system by MT4 appears a bit naff to me.
pkmojuspk
12-15-2022 02:55,
Hey everyone I am having a issue with the R API that is truly perplexing. I can conduct an EA and utilize RExecuteAsync(), RAssignVector(), etc.. . I am currently passing vectors to R and then calling an R script file to run computations on the vectors that were passed and plot some metrics. My plot() call in my R script will work a few times (i.e. the R script will properly plot the metrics, I will shut the plot window and following time start() is called from the EA the plot will show back up again) and then will stop working. I don't have any idea why this is happening or what's going on. Has anyone else experienced this?
Edit: Solved the issue, there was a mistake in my MQL4 evaluation script that was not within my R test script. I also am posting my progress on some cointegrated trading progr, don't hesitate to test it out at my site: http://www.pamexx.com
Issi2004
12-15-2022 03:01,
The joke was on me. I began a couple of MT4 platforms and they didn't provide the exclusion error leaving debugview window hushed. It was that I had a DLL based indior running at the MT4 on another chart that has been minimised which caused the exclusion error on that MT4 platform, nothing related to R.
aloxspumoeslilo
12-15-2022 03:11,
I think that your work is wonderful. Congratulations on your work.
I was searching at the arima indior.
I changed a few lines of code to attempt and use the auto.arima role in R.
It compiled OK but when I attempted to use it I did not get anything on the chart.
I checked the code but I can't figure out what I am doing wrong.
Is it possible to post a couple more indior examples using R capabilities. That would be helpful.
Bammenga
12-15-2022 03:18,
I think your work is really amazing. Congratulations on your amazing work.I was appearing in the arima indior.I changed a couple of lines of code to try to use the auto.arima role in R.It compiled OK but when I attempted to use it I did not get anything on the chart.I assessed the code but I can't figure out exactly what I am doing wrong.Is it possible to post a couple more indior illustrations using R functions. That would be helpful. Adamfx, you might also post your code to let's check if there's any problem, 7bit used simple OLS way in his sample code which can be readily adapted to other regression even like svm lt;- I am testing this.
Flaoxvemge
12-15-2022 03:28,
Also a big THX to 7bit - I have this working under Ubuntu 12.10, running MT4 v500 and R 3.0.1 under wine. I'm hoping to link ticks to some tick stream analyzer in R. I'll set up a site, finally to report.
Bammenga
12-15-2022 03:34,
It appears I'm undoubtedly not the only one who enjoys the R MT4 interface of 7bit. :--RRB-
I have been trying to setup an EA to check couple of models with R interface, but I am stucked in the very beginning of using 7bit's indior code to build an evaluation EA framework, the Print does not throw out anything in the log window, I'm not a programmer so do't blame me the bad structurehttps://www.nigeriaforextrading.com/attachments/1530271017.png and that I really do appreciate if anybody would give me some clues for the below code.
Inserted Code #property copyright #65533; Bernd Kreuss #include lt;mt4R.mqhgt; #include lt;common_functions. Mqhgt; extern int back = 500; extern int order = 200; extern int forward = 20; extern string R_command = C:RR-3.0.1bini386Rterm.exe --no-save; extern int R_debuglevel = 2; int rhandle; int init() rhandle = RInit(R_command, R_debuglevel); int deinit() RDeinit(rhandle); int begin () double hist#91;#93;; double pred#91;#93;; double buf_prediction#91;#93;; int I; ArrayResize(hist, back); for (I=0; ilt;back; I ) hist = Close; //fill up the hist array with Close price RAssignVector(rhandle, hist, hist, ArraySize(hist)); //Can I still need this? RExecute(rhandle, hist lt;- rev(hist)); //get into the ideal order in time RAssignInteger(rhandle, ord, order); RExecuteAsync(rhandle, model lt;- ar(hist, aic=FALSE, order=ord, method='ols')); //build the ols version if (RGetInteger(rhandle, as.integer(exists('model'))) == 1) // there is a model (the variable is defined ). // This usually means a previously started RExecuteAsync() has completed. // we can forecast from this model and plot it. RAssignInteger(rhandle, forward, forward ); RExecute(rhandle, pred lt;- predict(model, n.ahead=forward )$pred); // if There's a model, forecast a forward value ahead ArrayResize(pred, forward ); RGetVector(rhandle, rev(pred), pred, forward ); for (I=0; ilt;beforehand; I ) buf_prediction = pred; //buffer of forecast ahead worth Printing (histNumber 91;1#93;-RRB-; Print (Close); Print (buf_prediction#91;1#93;-RRB-; RExecute(rhandle, save.image()); return(0);
P3mc3v4l
12-15-2022 03:42,
croupier,
View the attached document. I simplified it a bit - with the simple (ier) interface rather than the original interface. I try to stay away from RExecuteAsync because you can't ensure that MT4 will execute as you think it should. Consequently I restricted updating in the start() function to once a pub to cut down on wasted processing time.
All this EA does is print out three numbers, but you should be able to get some comments .
Also see the variable to toggle save / no save for your picture and a file path. Note the arrangement of the strings used to get a quote within a string. (backslash quote)
https://www.nigeriaforextrading.com/attachments/1530271040708853498.mq4
when I attempted to complied the mt4r.mqh document I had the following erroes: These are not errors, they're warnings. Its the compiler which is warning about nothing. Its background noise. Unfortunately there's absolutely no way to turn them off (which is slightly annoying). You may safely ignore them.
Hello and thank you for the interesting thread. Your indior doesn't run, maybe because it doesn't find the ar function in R. See the debugview (sorry if some prints are in spanish):
[12036] lt;2gt; Create: trying to start R: C:/Archivos de programa/R/R-2.13.2/bin/i386/Rterm.exe --no-save
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; options(digits=15)
[12036] lt;2gt; ExecuteCode: out lt;lt;lt;
[12036] lt;2gt; Create: R successfully started
[12036] RInit: RHandle = 33EAF8C (54439820)
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; as.integer(as.integer(exists('model')))[1]
[12036] lt;2gt; ExecuteCode: out lt;lt;lt; [1] 0
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; hist lt;- c(1.38433, 1.38459, 1.38505, 1.38588, 1.38438, 1.38599, 1.38566, 1.38344, 1.39228, 1.39452, 1.39267, 1.39467, 1.39839, 1.39914, 1.40012, 1.40131, 1.40116, 1.39972, 1.39948, 1.4044, 1.40317, 1.39974, 1.39903, 1.40144, 1.40473, 1.40919, 1.41505, 1.41379, 1.41468, 1.41574, 1.41543, 1.41674, 1.41614, 1.41636, 1.41759, 1.41551, 1.41649, 1.41587, 1.41571, 1.41744, 1.41779, 1.41701, 1.41831, 1.41852, 1.41732, 1.41682, 1.41686, 1.4174, 1.41832, 1.41983, 1.41731, 1.41844, 1.41883, 1.41853, 1.42103, 1.42319, 1.41846, 1.41709, 1.41429, 1.41263, 1.40674, 1.40294, 1.40309, 1.40181, 1.39921, 1.4007, 1.40105, 1.39904, 1.39782, 1.39694, 1.39562, 1.39734, 1.3915, 1.3885, 1.38758, 1.38948, 1.3906, 1.39048, 1.38968, 1.38907, 1.38304, 1.38373, 1.38208, 1.39068, 1.39313, 1.3927, 1.39176, 1.39364, 1.39203, 1.39369, 1.39258, 1.3915, 1.39195, 1.39225, 1.39218, 1.39279, 1.39207, 1.38996, 1.39029, 1.39086, 1.39073, 1.39021, 1.39278, 1.39311, 1.3917, 1.39102, 1.3903, 1.38865, 1.39025, 1.39379, 1.39394, 1.39262, 1.39206, 1.3928, 1.38873, 1.38985, 1.39067, 1.39076, 1.39037, 1.39177, 1.39078, 1.39192, 1.39217, 1.39319, 1.39278, 1.39259, 1.39476, 1.39452, 1.3921, 1.39313, 1.38822, 1.38408, 1.38594, 1.386, 1.38259, 1.38618, 1.38576, 1.38899, 1.39191, 1.39295, 1.38898, 1.38815, 1.38768, 1.38609, 1.38499, 1.38497, 1.38448, 1.38926, 1.38963, 1.38667, 1.38324, 1.38563, 1.38723, 1.38962, 1.3886, 1.38281, 1.38095, 1.37529, 1.3779, 1.37516, 1.37355, 1.37582, 1.37915, 1.37772, 1.37747, 1.37802, 1.37761, 1.37779, 1.37938, 1.37768, 1.37765, 1.37806, 1.37819, 1.37684, 1.37304, 1.37062, 1.36717, 1.36981, 1.37494, 1.37706, 1.38004, 1.38103, 1.38014, 1.3727, 1.37115, 1.37075, 1.37023, 1.37152, 1.37255, 1.37325, 1.37484, 1.37617, 1.37668, 1.3763, 1.37592, 1.37597, 1.37504, 1.37473, 1.37807, 1.37859, 1.37742, 1.38021, 1.38028, 1.38567, 1.3819, 1.3845, 1.38512, 1.38234, 1.38121, 1.3796, 1.38159, 1.38111, 1.38023, 1.37757, 1.37655, 1.37633, 1.37318, 1.37338, 1.37335, 1.37513, 1.37638, 1.37413, 1.37326, 1.3739, 1.37182, 1.3683, 1.36596, 1.37017, 1.36701, 1.36988, 1.36822, 1.3685, 1.3714, 1.37431, 1.37752, 1.3774, 1.37826, 1.37685, 1.37748, 1.37665, 1.3745, 1.37426, 1.37357, 1.37372, 1.3745, 1.37432, 1.37656, 1.37714, 1.37684, 1.37649, 1.3759, 1.37861, 1.37791, 1.37957, 1.38404, 1.38925, 1.38906, 1.38687, 1.3851, 1.3848, 1.38434, 1.38521, 1.3859, 1.38618, 1.3873, 1.38774, 1.38765, 1.38781, 1.3877, 1.38732, 1.38515, 1.38596, 1.38666, 1.38697, 1.3795, 1.37943, 1.37923, 1.37973, 1.37995, 1.37686, 1.37811, 1.3786, 1.37719, 1.376, 1.37501, 1.3759, 1.37234, 1.37522, 1.37337, 1.37717, 1.37769, 1.37856, 1.37823, 1.37682, 1.3747, 1.37292, 1.37053, 1.37016, 1.37331, 1.37343, 1.37396, 1.37255, 1.37383, 1.38084, 1.37818, 1.37854, 1.37998, 1.3794, 1.37829, 1.37786, 1.37852, 1.37777, 1.37894, 1.37786, 1.37913, 1.3791, 1.37908, 1.38259, 1.38112, 1.38042, 1.37946, 1.37845, 1.37875, 1.37604, 1.37708, 1.37965, 1.37649, 1.36882, 1.36623, 1.36325, 1.3614, 1.36136, 1.36077, 1.35986, 1.36098, 1.36329, 1.36443, 1.36487)
[12036] lt;2gt; ExecuteCode: out lt;lt;lt;
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; hist lt;- c(hist, 1.36392, 1.36792, 1.36617, 1.3676, 1.36409, 1.36561, 1.36349, 1.35954, 1.35863, 1.35877, 1.35978, 1.3605, 1.35924, 1.36363, 1.36386, 1.36395, 1.36309, 1.36251, 1.36245, 1.36449, 1.36319, 1.36261, 1.36338, 1.36342, 1.36415, 1.36501, 1.36481, 1.3658, 1.36602, 1.36832, 1.36552, 1.36342, 1.36174, 1.35829, 1.35889, 1.35589, 1.35682, 1.35334, 1.34652, 1.3471, 1.34787, 1.34577, 1.34404, 1.34545, 1.3443, 1.33993, 1.33836, 1.33805, 1.33861, 1.339, 1.34092, 1.33916, 1.35118, 1.34914, 1.34822, 1.34825, 1.34368, 1.34374, 1.34244, 1.343, 1.34459, 1.34397, 1.34273, 1.34249, 1.3436, 1.34252, 1.34208, 1.34093, 1.34266, 1.3428, 1.34273, 1.34365, 1.34495, 1.34238, 1.34269, 1.33956, 1.34069, 1.34039, 1.33354, 1.32855, 1.32867, 1.33505, 1.33668, 1.33748, 1.3337, 1.33434, 1.33337, 1.33283, 1.33293, 1.33268, 1.33402, 1.33388, 1.33434, 1.33389, 1.33472, 1.33474, 1.33456, 1.33576, 1.33567, 1.33102, 1.33264, 1.33121, 1.33056, 1.33111, 1.33299, 1.33521, 1.33034, 1.3321, 1.3297, 1.33263, 1.331, 1.33115, 1.3288, 1.32933, 1.32855, 1.32818, 1.33168, 1.33266, 1.33365, 1.33496, 1.33205, 1.32391, 1.32413, 1.32739, 1.32931, 1.32794, 1.31916, 1.3192, 1.31776, 1.3182, 1.32075, 1.31886, 1.31568, 1.32219, 1.32156, 1.32039, 1.31972, 1.32025, 1.3215, 1.31962, 1.319, 1.31928, 1.31906, 1.31757, 1.3203, 1.32198, 1.32441, 1.32684, 1.32802, 1.32745, 1.33159, 1.331, 1.335, 1.33637, 1.33439, 1.33274, 1.33551, 1.33333, 1.33186, 1.33267, 1.33251, 1.33317)
[12036] lt;2gt; ExecuteCode: out lt;lt;lt;
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; hist lt;- rev(hist)
[12036] lt;2gt; ExecuteCode: out lt;lt;lt;
[12036] lt;2gt; ExecuteCode: in gt;gt;gt; ord lt;- 200
[12036] lt;2gt; ExecuteCode: out lt;lt;lt;
[12036] lt;2gt; ExecuteCodeAsync: starting separate thread
[12036] lt;2gt; ExecuteCodeAsync: in gt;gt;gt; model lt;- ar(hist, aic=FALSE, order=ord, method='ols')
[12036] lt;0gt; GetOutput: Error: R isn't running (anymore): model lt;- ar(hist, aic=FALSE, order=ord, method='ols')
[12036] Error: no se pudo encontrar la función ar
[12036] Ejecución interrumpida
[12036] lt;-1gt; TPlotEventLoop: terminating
What can I do?
leopmokliel
12-15-2022 04:09,
You need install bundle ARMA earlier in R
Thanks Surfeur, but I really don't find where is ARMA bundle... Where do I download it?
Simply I should install P release of R
Fantastic work!
Could you notify that the optimization workflow to obtain the pair of parameters for the autoregression?
[Keywords: mt4R.dll, mt4R.mqh, R, Metatrader]
Hello,
perhaps some of you want to experiment with my MT4 R port which allows one to start as numerous R sessions (usually one per running EA), move data forth and back and call R functions. The R sessions will be conducted as separate processes in the background however, the API towards mql4 are function calls, polling and writing files. Communiion goes through stdio pipes to and from each of the R processes.
Within this .zip file will be the needed files (mt4R.mqh and mt4R.dll)...
Ouchemok
12-15-2022 04:33,
Can I delegate a long multi-line function?
If I attempt to put it all on the same line I then move over MQL4's series size limitation, and if I attempt to break up the function deceleration into separate claims afterward R just stalls. .
Instance:
GetTopNlt;-function(n)
for(I in 1:nrow(actionlist))
c[I,1]lt;-actionlist$OpenTime[I];
c[I,2]lt;-cor(z[actionlist$RPos[I] n1,2],x[,2]);
c[I,3]lt;-cor(z[actionlist$RPos[I] n1,3],x[,3]);
c[I,4]lt;-cor(z[actionlist$RPos[I] n1,4],x[,4]);
c[I,5]lt;-cor(z[actionlist$RPos[I] n1,5],x[,5]);
avc lt;- (cbind(c[,1],rowSums(c[,2:5])));
topx lt;- c[order(avc[,2], decreasing=TRUE),1][1:n];
bottomx lt;- c[order(avc[,2], decreasing=FALSE),1][1:n];
Tlt;-as.data.frame(c(topx,bottomx),row.names=NULL);
colnames(T)[1]lt;-OpenTime;
sqlSave(channel,dat=T,tablename=ReducedList,append =FALSE,rownames=FALSE,safer=FALSE);
sqlQuery(channel,DELETE FROM ActionList WHERE OpenTime NOT IN (SELECT OpenTime FROM ReducedList));
Pablllp30
12-15-2022 04:39,
These are not errors, they are warnings. Its the dumb compiler that's warning about essentially nothing. Its background sound. Unfortunately there is absolutely no way to turn them off (which is slightly annoying). You can safely ignore them. Dear 7bit;
Do you know that there is a Cuda implementation for R, I suppose you've got some strategies to enhance your DLLs.
In case you don't have any, I am willing to work with you about the development.
Waiting for your kind reply.
Dorial.
Looks like you didn't enter the path into the directory of your R setup .
Have you ever installed R yet? If that's the case, you still need to stage whatever indior you compose to the R installation directory as stated in mt4R.mqh.
Callammes
12-15-2022 04:58,
Seems like you did not enter the path to the directory of the R setup properly.
Have you installed R yet? If so, you still need to point whatever indior you write to the R installation directory as specified in mt4R.mqh. Thank you, I was doing all right, but it works, simply use a 4 digit broker!
Thanks again https://www.nigeriaforextrading.com/attachments/1530271058.png
bycho2818
12-15-2022 05:26,
Hi,
Very excellent effort to connect R to MT4 that makes egy implementation alot simpler and simpler.
However, how do I get the DebugView to work properly?
What I am getting is as connected
https://www.nigeriaforextrading.com/attachments/15302710642010965346.png
P3mc3v4l
12-15-2022 05:34,
Employing 7Bit's good mt4R.dll tool that I interpreted the Metatrader port into a VB6 class that can make the calls into 7Bit's dll. This implies VB6 / VBA developers are now able to connect their appliions to R by means of a very simple class interface to harness all the power of a true statistical computing environment, R without additional COM overhead requred by (D)Com Statconnector.
Https://sites.google.com/site/marketformula/vb6-to-c/vb6-to-c-downloads/calling-r-from-vb6-vba
Included in the download is a demo appliion to show the way to implement R in your VB6 code using the cMT4R class.
I posted about this a year ago but have been quite busy and only got around to upgrading / completing it. I did get VB6 matrices to work in R. Just note that in R the order goes:
Inserted Code A#91;row, column#93;
While in VB6 / VBA you declare your array as:
Inserted Code A(column, row)
P3mc3v4l
12-15-2022 05:43,
After making the translation, I decided I had to access R. So I interpreted the VB6 course to C# so that C# .NET developers may now access R using 7Bit's mt4R.dll.
C# / .NET developers can link their appliions to R by means of a very simple class interface to exploit all the energy of an authentic statistical computing environment, R.
https://sites.google.com/site/marketformula/vb6-to-c/vb6-to-c-downloads/calling-r-from-csharp-dotnet
Included in the download is a demo appliion to show the way to implement R in your C# code working with the cMT4R course.
The matrix operation caveats mentioned regarding VB6 arrays are not a problem for C# developers. R and C# matrices are equally arranged as:
row, column
Can you give a few examples to us and interpret it?
P3mc3v4l
12-15-2022 06:05,
Could you translate it to MQL5 and give us a few examples? Sorry, I don't use MT5.
Xavi4585
12-15-2022 06:23,
FXEZ thanks for your job...
It's funny you were porting this. I was porting the interface to 7bit's DLL to C a couple of months ago and got stumped with a runtime exception. I didn't want it so I continued with my current endeavors figuring I'd return to it.
Bammenga
12-15-2022 06:45,
Is 7bit maitaining this MT4R API?
I downloaded the zip file and installed to MT4, tried the example code for auto-regression but othing really showed up in the MT4 terminal, same for the 2 sample EAs (Trend-O-Mat and Arb-O-Mat), only wonder if something wrong with the R variant (I use R-2.15.2, and MT4R variant 1.3.0.27). Thanks.
P3mc3v4l
12-15-2022 06:53,
Is 7bit still maitaining this MT4R API?
I downloaded the zip file and installed to MT4, tried the example code for auto-regression but othing actually showed up in the MT4 terminal, same for both sample EAs (Trend-O-Mat and Arb-O-Mat), only wonder if something wrong with the R variant (I use R-2.15.2, also MT4R variant 1.3.0.27). Thanks. I guess I am on the help desk now...
Croupier, see this article
https://www.nigeriaforextrading.com/trading-discussion/20-eur-usd-effectively-unchanged-overnight.html
and then scroll up to post #9 and see if any of that gives you some ideas to debug your problems.
FYI IIRC I don't think it works with 64 bit in MT4. Use 32 bit R with 32 bit MT4
Fman3218
12-15-2022 07:00,
This is nothing to fret about. Okay, thanks!
Albempk19821982
12-15-2022 07:11,
I came across this today,Sat I am not sure I have everything set up as it is the week end Will the ea show anything without a ticks coming through
or will it show beyond bar history.... In other words does this just work during trading hours
Due
I came across this now,Sat I am not sure I have everything setup as it's the week end Will the ea reveal anything with no ticks coming via
or will it reveal past bar history.... In other words does this just work during trading hours
Due It requires ticks to trigger the start() function. There are scripts which can simulate this on weekends.
For instance this to deliver a continuous stream of ticks into the chart:
Inserted Code /** * MT4/experts/scripts/ticks.mq4 * send a bogus tick each 200 ms into the chart and * all its indiors and EA until this script is removed. */ #property copyright © Bernd Kreuss #import user32.dll int PostMessageA(int hWnd, int Msg, int wParam, int lParam); int RegisterWindowMessageA(string lpString); #import int start() int hwnd = WindowHandle(Symbol(), Period()); int msg = RegisterWindowMessageA(MetaTrader4_Internal_Messag e); while(! IsStopped()) PostMessageA(hwnd, msg, 2, 1); Sleep(200); or the subsequent one to send just 1 tick and then exit (I have this attached to a hotkey Alt T on my platform for convenience):
Inserted Code /** * MT4/experts/scripts/one_tick. Send one bogus tick into the chart and * all its indiors and EA and exit. */ #property copyright © Bernd Kreuss #import user32.dll int PostMessageA(int hWnd, int Msg, int wParam, int lParam); int RegisterWindowMessageA(string lpString); #import int start() int hwnd = WindowHandle(Symbol(), Period()); int msg = RegisterWindowMessageA(MetaTrader4_Internal_Messag e); PostMessageA(hwnd, msg, 2, 1);
__________
this appears to be my two ^10th article in this forum
.
Albempk19821982
12-15-2022 07:29,
Thanks that worked just wanted to make sure I have it put right
this is very interesting and I don't know anything about it
but I have been playing basket pairs
like
AUDUSD,EURUSD,GBPUSD if market
USDCAD,USDCHF,USDJPY afterward buy or vise versa
with this I could burden the lot sizes
but just thinking outloud and studying a lot
Albempk19821982
12-15-2022 07:38,
would this imply I'd
buy AU 2 lots
sell EU 2 lots
GU nothing
Ucad sell 2 lots
Uchf nothing
UJ sell 1 lot
what exactly does the (0) represent?
https://www.nigeriaforextrading.com/attachments/15302710961632233024.png
would this mean I would
buy AU two lots
sell EU two lots
GU nothing
Ucad sell two lots
Uchf nothing
UJ sell 1 lot Yes, but you should increase base_lots for larger (and more precise) numbers. You are able to try them onto an oanda demo account next week, there you are able to trade in units and not in lots and have much more flexibility at the lot sizing (1 lot == 100000 units and you are able to exchange as small as 1 device ).
Also try the other EA I posted in one of the recent postings: trendomat.mq4 it has some experimental new configurations.
Albempk19821982
12-15-2022 07:53,
Been playing with both all day
lummele777
12-15-2022 08:04,
Oh I managed to run it, I mispelled the address. Although the thing seems to not be painting. I wonder ...
I left it run, Great package! Thanks 7bit
oxmlabenejam.moxx
12-15-2022 08:14,
It requires ticks to activate the start() function. There are.
For instance this to send a continuous stream of ticks to the chart:
[code]
/ / **
* MT4/experts/scripts/ticks.mq4
* send a bogus tick every 200 ms to the chart and
* all its indiors and EA until this script is removed.
Decision /
#property copyright © Bernd Kreuss
#import user32.dll... phwoar that is a wicked hack. Have not used it but can see the possibility.
Question 1: can this be used to'create' a bogus emblem and then stream data to it? An program could be installed as the'host' sending data?
Or, you might stream bogus data to a fresh exotic emblem you'd not actually need to trade but can load to mt4... that way you aren't breaking any data on your own real-traded charts.
Question two: can this be used to set a custom spread? (or was that the stage and I am too tired to realise?)
samk3000
12-15-2022 08:25,
Hello,
7-bit I have 2 questions:
1) Any plans for MQL5?
2) Can I somehow use mt4Rdll to use under Linux? MT4 is conducted under wine and I am using Linux native R.
samk3000
12-15-2022 08:32,
Hi,
7-bit I have Two questions:
1) Any plans for MQL5?
2) Could I somehow use mt4Rdll to use under Linux? MT4 is run under wine and I am using Linux native R. I have a concept for my queries, but anyway your library convince me to think. My queries are obsolete.
Jesusynemea
12-15-2022 08:41,
Can I Maximize mt4r.dll on windows 7 x64?
Exebemmay1
12-15-2022 08:51,
As soon as I attempted to complied the mt4r.mqh document I had the subsequent erroes:
Start function not found and cannot be run.
Function RInit is not referenced and will be removed from exp-file
Function StartR is not referenced and will be removed from exp-file
Function StopR is not referenced and will be removed from exp-file
Function Rx is not referenced and will be removed from exp-file
Function Rs is not referenced and will be removed from exp-file
Function Ri is not referenced and will be removed from exp-file
Function Rd is not referenced and will be removed from exp-file
Function Rv is not referenced and will be removed from exp-file
Function Rm is not referenced and will be removed from exp-file
Function Rgi is not referenced and will be removed from exp-file
Function Rgd is not referenced and will be removed from exp-file
Function Rgv is not referenced and will be removed from exp-file
Function Rp is not referenced and will be removed from exp-file
0 error(s), 14 warning(s)
anyone know what was the cause for it?
i am running it under windows 7 32bit and R 2.13.1.
thanks.
P3mc3v4l
12-15-2022 09:00,
7Bit, fantastic job on producing mt4R.dll. I have cobbled a wrapper for VB6 up for my private use. Maybe I will make it available if anyone is interested, if I get some time. I'm beginning to find the options of R but've encountered a few problems in making a full working translation of mt4R.mqh.
The two matrix routines RAssignMatrix and RAppendMatrixRow are giving me problems. It may be that Pascal and VB6 matrix constructions are incompatible for multi-dimensional arrays, or more probable that my infantile understanding of R / Pascal and they manage arrays/matrices is your issue. Case in point: I do not even know how to test matrix / vector boundaries within R.
I guessed a workaround with RAssignVector, and then mixing a temporary vector in an already dimensioned matrix in R one column at a point: Inserted Code Rx(multiA#91;,1#93; lt;- tempA) reproduces tempA to column 1 of multiA. Repeated in a loop, this approximates the functionality of RAssignMatrix.
It seems that RRowBindVector(), that is mentioned in the RAssignMatrix remarks of mt4R.mqh is not found in the mt4R.dll source code. Is this just an allusion to utilizing the Inserted Code * factor lt;- rbind(variable, vector) command within R or a function which didn't yet make it to the DLL?
7bitI see you've made this way to use R. I made an R program that forecasts the price later on, and comes with the proper amount to exchange. It trades 7 currency pairs at once. It runs after an hour. It makes a table with all the trades I need to do I manually input them.
I Would like to automate it onto a broker. It looks like OANDA would work, they've a Metatrader platform, and I have used a clinic account for awhile today.
My problem isI have zero experience with MQL4, or any other programming languages. I don't know where to get started. I can't do that all of the time, although I had been testing it out on OANDA manually. Would you be willing to help me out to get my program automated?
Being a new memberI don't know if I can respond to personal messages, but should you need my email, I will provide it to you. Thanks.
7Bit, great job on producing mt4R.dll. I have cobbled up a wrapper for VB6 That is an interesting idea. The method by which in which the dll was created (a simple horizontal C-like interface) it should be simple to use it with a lot of different languages which can interface with native DLLs.
The two matrix patterns RAssignMatrix and RAppendMatrixRow are giving me problems. It can be that VB6 and Pascal matrix constructions are more likely, or incompatible for arrays they manage arrays/matrices is your issue and my infantile comprehension of R / Pascal. Case in point: I don't even know how to test matrix / vector bounds within R. The arrangement that is used is the one which is dictated by the way the 2-dimensional mql4 array resembles, there's not anything special about Pascal types, they're just like C types on the lowest machine degree and therefore are laid out the same.
In C it could be a double * foo and you might dereference it with foo[x], in Pascal you essentially do the same with a foohttps://www.nigeriaforextrading.com/attachments/1530271088.pngDual, the syntax is different (simpler for humans, more natural, simpler ( less ambiguous) the representation about the machine degree is precisely the same as the equal in C.
The matrix (or 2-dimensional variety ) for example:
1 2 3
4 5 6
7 8 9
will be reflected in memory just like a horizontal 1-d range:
1 2 3 4 5 6 7 8 9 (at this point without looking into the code now from the top of my head I'm not 100% sure it might also be transposed):
1 4 7 2 5 8 3 6 9 (but that can easily be discovered )
and actually in my dll I'm passing 2d arrays because 1d arrays and 2 variables defining the row and column count.
Passing a range (no matter how many dimensions) to the dll from mql4 means passing the pointer to a memory block comprising such a horizontal row of numbers, each number as 8 byte double, no header, no separators, only the numbers. 9 elements' above mentioned example matrix could be passed as a pointer. An 1D range would seem the exact same, its row and column count that tells my code how to read it.
I'm not sure how in VB a 2D array is coordinated, if it functions the same way it should be possible there too. If the 2D arrays are somehow structures than described above then you might attempt to create the matrix a one dimensional array and move that to RAssignMatrix along with the row and column count.
I figured a workaround with RAssignVector, and then combining a temporary vector into an already dimensioned matrix in R 1 column at a time: Inserted Code Rx(multiA#91;,1Number 93; lt;- tempA) reproduces tempA to pillar 1 of multiA. This approximates RAssignMatrix's functionality. That is perfectly ok if it doesn't produce a performance bottleneck, RAssignMatrix() needs to be faster but this is dependent upon how big the structure is (it'd be *much* faster with very big matrices) and just how slow or fast the rest of the code is to make this a significant bottleneck.
It seems that RRowBindVector(), that is mentioned in the RAssignMatrix comments of mt4R.mqh is not found in the mt4R.dll origin code. I have changed the API several times and removed and replaced a few functions, most likely I forgot to alter this remark and it is still referring to a older version where this function still existed.
___
[edit:] double has just 8 bytes of course, I confused it with something different. An individual can certainly forget (and also safely ignore) this when using a language with strong typing and typed pointers rather than being forced to mess up with void pointers all afternoon long.
phwoar that is a hack that is wicked. Have not used it but can see the potential.
Query 1: can this be used to'create' a fake symbol and then flow information to it? An program can be installed as the'server' sending data internally?
Or, you might flow fake data to an unused exotic symbol you would not actually need to trade but may load to mt4... that way you are not breaking any info on your own real-traded charts.
Question two: can this be used to specify a custom spread? (or was that the stage and I'm too tired to realise?) q1: yes. Write to the .hst file and send a tick to the chart window to update it. Should work.
Q2: the spread has been managed somehow differently. To decide on a diffferent spread for backtesting you have to disconnect MT4 from the net so it cannot call home and ask for the current spread then modify a file in the history folder, there should be a few threads about this here and on mql4.com.
Looks like something simple failed:
Inserted Code #91;2988#93; installed exception handler for C:Program FilesMetaTrader Admiral Markets ASexpertslibrariesmt4R.dll #91;2988#93; lt;2gt; Produce: trying to start R: C:ProgrammeRR-2.11.0binRterm.exe --no-save #91;2988#93; lt;-1gt; TRConsole: ruining #91;2988#93; eliminated exception handler for C:Program FilesMetaTrader Admiral Markets ASexpertslibrariesmt4R.dll It cannot start the RTerm.exe, be sure the route in
extern string R_command is right (the model number changes from time to time), check it very closely and when R is installed and the path is right it should function.
Can I Maximize mt4r.dll on windows 7 x64? You need to use the 32 bit compiler (download the 32 bit IDE, it includes the 32 bit compiler), MT4 itself is a 32 bit appliion and can only load 32 bit dlls. In case you used the 64 bit version of Lazarus/FPC binaries would be produced by it by default and this wouldn't work with MT4.
You can even setup cross compiling from within precisely the exact same setup (if you plan on using Laz/FPC for other projects also, but the setup is more complied, I have not done this). And for MT4R it isn't feasible, it's strictly intended to be windows.
The fantastic news is that 32 bit appliions run just fine on 64 bit windows.
I just noticed that it'll leak a thread handle on each call to RExecuteAsync(), this really is an issue if you leave it running for a few days. The main reason is I had been too lazy to use the TThread class as it would have been the recommended way but rather quickly hacked a BeginThread() into my current code without even caring about the thread handle afterwards. I am preparing a new release which will fix this issue.
I'm now preparing a new release which will fix this issue. Uploaded new variant 1.2.0.36 which fixes this issue.
LaumaySalvi
12-15-2022 10:06,
Uploaded new variant 1.2.0.36 which fixes this issue. Thanks Bernd!
7bit,
is there a way to use this port under Linux running Metatrader using Wine?
,
is there a way to utilize this interface under Linux running Metatrader with Wine? I haven't tested it. It will (since it assumes it is running in windows) attempt to start (with the help of wine) the windows* executable ~/.wine/drice_c/.../rterm.exe (not /usr/bin/R) since inside the wine surroundings it has no idea that there could exist anything out ~/.wine/ (and the way such a strange alien universe [the OS that lives outside] might look like function) and that is the reason the wine execution of the windows API CreateProcess() could not start indigenous linux executables anyways, even though it had the correct path name. It could not cross this border.
You'll have to put in the windows version of R in wine and it should theoretically work. (untested but this is the way it should work in theory).
AlexGlwz08
12-15-2022 10:29,
You are the usual genius... I had been doing so with sockets so far, and I am sorry for all of the dual to char array conversions I forced my cpu to carry out.
Cant wait to check this, thanks.
you are the usual genius... I had been doing so with sockets so far, and I am sorry for all the dual to char array conversions I forced my cpu to carry out.
Cant wait to test this, thanks. There are still dual to char and char to dual conversions for vectors, only in the event that you move a matrix it will compose the whole raw memory block because it's into a temp file and then read.bin() with R. Nonetheless, as there is absolutely no polling 11, it's fairly fast and the temp file writing is so quickly that the majority of it occurs in the file cache only.
The typical roundtrip time for a simple RExecute() is ~300µs on my slow laptop. (measured using a separate .exe that loads my dll, maybe not with mql4)
AlexGlwz08
12-15-2022 10:50,
There continue to be dual to char and char to dual conversions for vectors, only in the event that you move a matrix it will write the whole raw memory block as it is to a temp file and then read.bin() together with R. But as there is absolutely no polling involved it is fairly fast and also the temp file writing is so fast that most of it occurs in the file cache just.
The typical roundtrip time to get a simple RExecute() is 300µs on my slow laptop. Oh well, I suppose we could always try using the writetobinary/readBin mechanism for passing vectors too, but it feels like we all have more cpus than we need these days.
You should take a look in the tcltk / tcltk2 packs for R; they have some sort of timer mechanism that runs in a different R ribbon -- you can use it to execute dummy R calls in fixed intervals so your R graphics windows dont block.
you should look into the tcltk / tcltk2 packs for R; they still have some type of timer mechanism that runs in another R thread -- you could use it in order to execute dummy R calls in fixed intervals so that your R graphics windows dont block. I could do this straight from my DLL (I already have the locking mechanism along with the thread that waits for the result of RExecuteAsync() to release the lock again, so this would not be much work. I'll apply it.
PS: I just made some measurements with mql4 along with the next code:
Inserted Code for(I=0; ilt;100000; I ) RExecute(R, ); needs 14 seconds, this means 140µs each RExecute(). Should I do something like
Inserted Code for(I=0; ilt;100000; I ) RGetInteger(R, 1 1); which translates to
Inserted Code as.integer(1 1) it requires 20 seconds (200µs per call).
The next assigns the exact same 100 component vector 100000 times:
Inserted Code double foo#91;100#93;; int I; ArrayInitialize(foo, 1.0/3); // odd amounts, long strings with 15 digits log(Start); for(I=0; ilt;100000; I ) RAssignVector(R, foo, foo, 100); log(End); needs 208 seconds (2.08 ms each vector). That remains 500 vectors or 50000 drops or roughly 0.8 Megabytes per second ascii information that's going through the pipe.
The same as above but each* vector as matrix: (transfer via file 10000 times create compose as.matrix(readBin()) delete)
Inserted Code double foo#91;100#93;; int I; ArrayInitialize(foo, 1.0/3); // odd amounts, long strings with 15 digits log(Start); for(I=0; ilt;100000; I ) RAssignMatrix(R, foo, foo, 100, 1); // 100 rows, 1 column log(End); 582 moments (5.8ms each vector (each being a file of 800 byte))
(Of course this is simply a stupid benchmark. When I had delegated a matrix of 100 x 100000 this would be only 1 control and one temp file of 80MB (8 bytes per double) and be accomplished in a couple of seconds.)
These amounts are from an old Pentium-M running in 1300MHz and wndows is operating within a virtualbox.
AlexGlwz08
12-15-2022 11:12,
Incidentally, if you ever want to do a version which uses R.dll directly (and consequently passes arrays natively), I would be happy to assist in any way I could, vc or lazarus. It would be imho.
Hi,
7bit thanks again for everything you're doing for this community.
Maybe I'm a bit off subject but on the weekend I had been somewhat documenting myself and that I came across with this open source toolbox.
Http://www.shogun-toolbox.org/
R examples.
Http://www.shogun-toolbox.org/doc/r__examples.html
Does anybody have experience with such a toolbox? We can open a separate thread for sharing experiences and view.
Claudio
This is: (save it as an indior in the indiors folder)
[code]
#property copyright © Bernd Kreuss
#property indior_chart_window
#property indior_buffers 1
#property indior_color1 Crimson
#property indior_width1 two
#include lt;mt4R.mqhgt;
extern int order = 200;
extern int back... Thank you for the great indior.Addition to yours I've discovered similar one in mql 5 codebase: http://www.mql5.com/ru/code/129
http://www.mql5.com/ru/code/134
Thanks for the great indior.Addition to yours I have discovered similar one in mql 5 codebase: http://www.mql5.com/ru/code/129
http://www.mql5.com/ru/code/134 At least 7bit is hoping to do us a favor converting mql5 into mql4, that is something difficult I locate myself.
It is easy to convert mql4 into mql5, but not the other way around.
I hope this provides a lineup for 7bit https://www.nigeriaforextrading.com/attachments/1530271116.png my friend.
Cheers,
Sf
Hello 7Bit,
Thank You a lot.
It's quite practical https://www.nigeriaforextrading.com/attachments/1530271116.png, also I mainly concentrate on the code itself so I will discover how things could be done, and might find some use of the code in the long run to execute a different thought.
Best wishes,
SF
I uploaded a new version. Current version is now 1.3.0.25, find it in post #1 in this thread.
Again we have some small API changes but you aren't losing any functionality. Also the .mqh file now also defines some shortcuts to its super lazy programmers among you who do not wish to type the lengthy function names, the handle along with the variety sizes all the time: simply call one of those Rx() and friends (defined in the base of mt4R.mqh.
An important change is that I have now decided to place it under the GPL license (NOT LGPL, I'm NOT Santa Clause, although I almost look like him!) . If you will need a commercial license for a closed source product please contact mepersonally, we may discover some agreement.
The library will now start a separate thread that addresses the refreshing of the plot window, so you don't have to worry about this anymore, so suspended plot windows should be a issue previously. Only call options(device='windows') from init and after that you can plot() and it is going to just work.
A couple of minor changes have been made to the API, RDebug() has been replaced with RPrint()this may call print() and send the output to the debug screen on debug level 0.
I have been using this variant now unchanged for more than a week, permanently stopping and starting multiple cases of R while shifting timeframes or recompiling all sorts of EAs and scripts, etc., without finding any issues. I can recommend this model and I will soon make a part on my website about it where you will find the most recent version.
Hello,
http://www.shogun-toolbox.org/
R Illustrations.
Http://www.shogun-toolbox.org/doc/r__examples.html
This looks like libshogun might also be directly obtained without using R (the shogun-R port doesn't look quite native to R, it almost looks as overseas to R because my mql-R interface looks overseas to mql). Maybe it's also possible to use it.
Someone should make a direct mql-shogun interface.
I conducted the debugview.exe and then began the terminal. It crashed with all the below mistakes in the debugview
[1520] installed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271116.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
[1520] lt;-1gt; TRConsole: destroying
[1520] removed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271116.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
[5216] installed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
[5216] lt;-1gt; TRConsole: destroying
[5216] removed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
Can it be of any help? Or shud I catch it.
I ran the debugview.exe and subsequently began the terminal. It crashed with the under mistakes in the debugview
[1520] installed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
[1520] lt;-1gt; TRConsole: destroying
[1520] removed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - lt Traderexpertslibrariesmt4R.dll
[5216] installed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - Meta Traderexpertslibrariesmt4R.dll
[5216] lt;-1gt; TRConsole: destroying
[5216] removed exception handler for Chttps://www.nigeriaforextrading.com/attachments/1530271117.pngrogram FilesFIGfx - lt Traderexpertslibrariesmt4R.dll
Can Be... could you put the debug level RDEBUG to 2 and try again?
Which variant of R do you have?
Did you place the correct RPATH in the EA?
Which version of windows are you working?
[Edit:] for confused readers of the thread: we are speaking about the EA that I submitted in the cointegration and mean reversion thread
[Edit2]: Problem found: You did not specify the right path to your Rterm.exe. You must configure this correctly in the file. I am conscious that it shouldn't be the behavior when this occurs, to crash, It should ch this gracefully and report the error instead. The next variant of mt4R.dll will get this fixed (I've fixed it already for another release). In the meantime make sure you always specify the proper path to Rterm.exe and it won't crash.
Fman3218
12-15-2022 14:10,
Maybe you could help me out...
When trying to compile the EA you posted in the very first page, I have warnings telling me that StartR, StopR, RX, etc. acts are not referenced and will be removed from the exp file.
Would you help me out?
I'm really eager to try out this as we've done a bit of actuarial modeling in faculty on R through GNU Emacs!
Maybe you could help me out...
When attempting to compile the EA you submitted in the first page, I have warnings telling me StartR, StopR, RX, etc. acts are not referenced and will be taken out of the exp file. This is nothing to worry about. It does observe it optimized the .ex4 by not including but never used in this EA. (They must be there since other EAs or indiors utilizing mt4R.mqh may need them). Other compilers do so optimizing too without mentioning it (at least not labeled as warning) but the mql4 compiler is somewhat talkative.
When it compiles but MT4 does instantly crash then the route towards the Rterm binary is not accurate.
Additionally you require DebugView.exe (from microsoft) should you want to produce your own scripts (and set the debug level in RInit() to two ) since it cannot use Print() it requires this to output debug messages and you have to view what's going on until your script is completely working.
It also helps for debugging and development to perform a RExecute(manage, save.image('c:/path/to/somewhere/ / file.R')) following some intermediate results to save the whole workspace, which means you can load it in a separate R console to scrutinize it interactively and test matters.
agolfobeamokle
12-15-2022 14:23,
Thanks samkar97! I had already solved this issue (I did not observe that the RExecute function initially ), but I am stuck on something else.
I discovered this mt-R library since I want OHLC data in realtime (stored every minute since the candles shuts, maybe not by tick) to work in R. Does anybody have a code for that?
I have a script that saves OHLC data perfectly, but it only works once (when moved to the chart). I really don't know MQL5. I can code in R.
agolfobeamokle
12-15-2022 14:31,
// ------------------------------------------------------------------
//| R_Prediction.Mq5 |
// ------------------------------------------------------------------
#property copyright
#property hyperlink http://www.forexfactory.com/showthread.php?t=260422page=10
#property version 1.00
#property stringent
#include lt;R.mqhgt;
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_label1 Prediction
#property indicator_width1 2
//input series InpCommand=d:\\R\\R-3.3.2\\bin\\x64\\Rterm.exe;//Path to Rterm.exe
input series InpCommand=C:\\Program Files\\R\\R-3.5.2\\bin\\x64\\Rterm.exe --no-save;//Path to Rterm.exe
enter int InpOrder=200;//Order
enter int InpBack=500;//Back
enter int InpAhead=20;//Ahead
double PredictBuffer[];
long R;
bool recalc;
const bool dll_allowed=MQLInfoInteger(MQL_DLLS_ALLOWED);
double hist[];
double pred[];
// ------------------------------------------------------------------
//| Custom indicator initialization function |
// ------------------------------------------------------------------
int OnInit()
//-- chart cancel
if(! ChartGetInteger(0,CHART_SHIFT))
ChartSetDouble(0,CHART_SHIFT_SIZE,20);
ChartSetInteger(0,CHART_SHIFT,true);
//--
SetIndexBuffer(0,PredictBuffer);
ArraySetAsSeries(PredictBuffer,true);
#ifdef __MQL4__
SetIndexShift(0,InpAhead);
#endif
#ifdef __MQL5__
PlotIndexSetInteger(0,PLOT_SHIFT,InpAhead);
#endif
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--
if(dll_allowed)
R=RInit(InpCommand --no-save,2);
if(R==0)
Comment(\nInvalid path:,InpCommand);
else
Comment(StringFormat(\nHistory:%d bars, method: OLS, order:%d,InpBack,InpOrder));
else
Comment(\nDLL calls Aren't allowed. Please change on this option) ;
//--
ArrayResize(pred,InpAhead);
ArrayResize(hist,InpBack);
//--
return(INIT_SUCCEEDED);
// ------------------------------------------------------------------
//| |
// ------------------------------------------------------------------
void OnDeinit(const int reason)
if(dll_allowed)
RDeinit(R);
Comment();
// ------------------------------------------------------------------
//| Custom indicator iteration serve |
// ------------------------------------------------------------------
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime timing [],
const double open[],
const double top [],
const double non [],
const double close[],
const long tick_volume[],
const long volume[],
const int spread[])
rates_total-prev_calculatedgt;0)
ArrayInitialize(PredictBuffer,EMPTY_VALUE);
//-- set'recalc' flag - need to make a new forecast
recalc=true;
if(! Recalc)
return(rates_total);
if(! Dll_allowed)
return(0);
//-- final RExecuteAsync() is still not completed, do nothing.
If(RIsBusy(R))
return(0);
//--
if(RGetInteger(R,as.integer(exists('model')))==1)
// there is a model (the variable is set).
// This usually means a previously started RExecuteAsync() has completed.
// we are now able to forecast from this model and plot it.
RAssignInteger(R,ahead,InpAhead);
RExecuteAsync(R,pred lt;- predict(model, n.ahead=beforehand )$pred);
RGetVector(R,rev(pred),pred,InpAhead);
for(int I=0; ilt;InpAhead; I )
PredictBuffer[I]=pred[I];
//-- apparent flag
recalc=false;
// create a (new) forecast
for(int I=0; ilt;InpBack; I )
hist[I]=close[I];
RAssignVector(R,hist,hist,ArraySize(hist));
RExecute(R,hist lt;- rev(hist));
RExecute(R, source('C:\\Users\\Orwell4\\Desktop\\Guesser\\Gues ser.R'));
//--
return(rates_total);
// ------------------------------------------------------------------
This doesn't work? My Guesser.R document contains this:
write.csv(hist, document = C:\\Users\\Orwell4\\Desktop\\Guesser\\result.csv)
2 Attachment(s) [Keywords: mt4R.dll, mt4R.mqh, R, Metatrader]
Hello,
maybe some of you want to experiment with my own MT4 R interface which allows one to begin as numerous R sessions (usually one per running EA), transfer data forth and back and call R functions. The R sessions will be conducted as separate processes in the background however, the API towards mql4 are synchronous function calls, writing and polling files. Communiion goes via stdio pipes to and from each of the R procedures.
Within this .zip file are the needed files (mt4R.mqh and mt4R.dll) for running this item. The .mhq file also includes all API documentation and other necessary information.
Https://www.nigeriaforextrading.com/trading-discussion/93-big-bucks.html
And optionally for those considering how the DLL functions below is the dll source code (it requires FPC 2.4.2 or newer to compile. You need to put in a current snapshot of Lazarus/FPC with a 2.4.3 compiler, you'll discover a current snapshot installer (IDE and Compiler in 1 bundle ) for win32 on ftp://ftp.freepascal.org/pub/lazarus/snapshots/):).
Here is the source:
https://www.nigeriaforextrading.com/trading-discussion/88-posting-trades-weblogger.html
The aforementioned documents are upgraded to the Most Recent version. Forget the preview files in place they are old.
Powered by nigeriaforextrading® Version 4.2.5 Copyright © 2026 nigeriaforextrading Solutions, Inc. All rights reserved.