Skip to content

Instantly share code, notes, and snippets.

@tomas-rampas
Created February 13, 2021 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomas-rampas/2eb532e7551de31a295ccf64218a67c3 to your computer and use it in GitHub Desktop.
Save tomas-rampas/2eb532e7551de31a295ccf64218a67c3 to your computer and use it in GitHub Desktop.
#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