Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,135 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
R strategy in Zorro Trader #463868
01/02/17 09:58
01/02/17 09:58
Joined: Apr 2013
Posts: 35
J
Joaquin Offline OP
Newbie
Joaquin  Offline OP
Newbie
J

Joined: Apr 2013
Posts: 35
Hi, I'm a newcomer to Zorro. I've been programming in mql4 for a long time. I have several strategies in R and would like to backtest and real trade them with Zorro.
The thing is that I don't know what is the best way to bridge a Zorro script with an R Session and don't keep reloading the R Session every new bar or tick.
I've tried in my script with a
Quote:
if (is(INITRUN)) {
if(!g->sRTermPath) {
printf("R path missing! ");
return;
}
if(!file_date(g->sRTermPath)) {
printf("%s not found! ",g->sRTermPath);
return;
}
string Cmd = strf("%s --no-save",g->sRTermPath);
printf(Cmd);
hR = RInit_(Cmd,2);
if(!hR) {
printf("Can't initialize RTerm! ");
return;
}

printf("nR initialized!");
Rx("library(tseries)");
printf("n%s",RLastOutput(hR));
if(!RIsRunning(hR)) {
printf("nR stopped!");
return;
} else
printf("nR running...");
}

section, and initializing the R session inside that code, but for that purpose I would need the R handler to be a static variable, right? And if I try the code
Quote:
static int hR;

it fails, as this variable is also used in the helper file...

With this code snippet of 'is(INITRUN) (...)' I have not been able to get it working. If I remove the is(INITRUN) clause the script works, but what I get is that every new candle the R Session is started, but it takes a looong time to complete (and it is nonsense to keep an R session starting and stopping every single execution of the main loop of the script, right?)
Could anybody give me a hint on how to achieve this?

Re: R strategy in Zorro Trader [Re: Joaquin] #463872
01/02/17 13:40
01/02/17 13:40
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You need not care of the R handle. It is already handled in the r.h header and not intended to be accessed by the user. For initializing R, just call RStart() in the INITRUN.

Re: R strategy in Zorro Trader [Re: jcl] #463888
01/03/17 09:02
01/03/17 09:02
Joined: Apr 2013
Posts: 35
J
Joaquin Offline OP
Newbie
Joaquin  Offline OP
Newbie
J

Joined: Apr 2013
Posts: 35
Thanks!


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1