Created
February 13, 2021 14:53
-
-
Save tomas-rampas/2eb532e7551de31a295ccf64218a67c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property strict | |
#include <mt4R.mqh> | |
extern string R_command = "D:\Program Files\R\R-3.3.1\bin\i386\Rterm.exe --no-save"; | |
extern int R_debuglevel = 2; | |
int rhandle; | |
int OnInit() | |
{ | |
rhandle = RInit(R_command, R_debuglevel); | |
return 0; | |
} | |
void OnDeinit(const int reason) | |
{ | |
RDeinit(rhandle); | |
} | |
void OnStart() | |
{ | |
int i; | |
int k; | |
double vecfoo[5]; | |
double vecbaz[5]; | |
for (i=0; i<5; i++) { | |
vecfoo[i] = SomeThingElse(i); | |
} | |
RAssignVector(rhandle, "foo", vecfoo, ArraySize(vecfoo)); | |
RExecute(rhandle, "baz <- foo * 42"); | |
k = RGetVector(rhandle, "baz", vecbaz, ArraySize(vecbaz)); | |
for (i=0; i<k; i++) { | |
Print(vecbaz[i]); | |
} | |
Print(TerminalInfoString(TERMINAL_DATA_PATH)); | |
} | |
double SomeThingElse(int n) | |
{ | |
return 1.25 * n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment