|
|
|
|
|
|
|
|
|
|
webGL
by Ice2642. 11/17/25 21:27
|
|
|
|
|
|
|
Training with the R bridge does not work
#488962
11/05/25 00:46
11/05/25 00:46
|
Joined: Jun 2023
Posts: 7
frutza
OP
Newbie
|
OP
Newbie
Joined: Jun 2023
Posts: 7
|
Hi, I am experimenting with the Zorro / R bridge. I have the following Lite-C script, which makes calls to R. #include <r.h>
function run()
{
set(PLOTNOW+PARAMETERS+LOGFILE);
BarPeriod = 1440;
LookBack = 100;
MaxLong = MaxShort = 1;
if(Init) {
if(!Rstart())
return quit("Error - R won't start!");
Rx("rm(list = ls());"); // clear the workspace
Rx("library(tseries)"); // load time series library
}
if(is(LOOKBACK)) return;
int size = optimize(50,10,100);
Rset("Data",rev(seriesC(),size),size); // send Close series to R
Rx("ADF = adf.test(Data)"); // Augmented Dickey-Fuller test
var adf = Rd("ADF$p.value");
if(adf > 0.6) enterLong();
if(adf < 0.6) exitLong();
plot("ADF p-value", adf ,NEW,RED); //display p-value
}
When I hit the train button, it takes the default value (50) and saves it in the .par file, but no actual training takes place. Once the value 50 is saved, I can hit test, and everything runs fine. However, there is no optimization happening. What am I doing wrong here? Thanks!
Last edited by frutza; 11/05/25 00:56.
|
|
|
Re: Training with the R bridge does not work
[Re: Petra]
#488983
11/19/25 22:32
11/19/25 22:32
|
Joined: Jun 2023
Posts: 7
frutza
OP
Newbie
|
OP
Newbie
Joined: Jun 2023
Posts: 7
|
Hi Petra, Thank you for your answer. I found (by trial and error) that my optimize call was misplaced within the code. I guess it has to be placed right at the beginning, after the flags and Zorro variables initialization. The following version of the code works as expected. #include <r.h>
function run()
{
set(PLOTNOW+PARAMETERS+LOGFILE);
BarPeriod = 1440;
LookBack = 100;
MaxLong = MaxShort = 1;
int size = optimize(50,10,100);
if(Init) {
if(!Rstart())
return quit("Error - R won't start!");
Rx("rm(list = ls());"); // clear the workspace
Rx("library(tseries)"); // load time series library
}
if(is(LOOKBACK)) return;
Rset("Data",rev(seriesC(),size),size); // send Close series to R
Rx("ADF = adf.test(Data)"); // Augmented Dickey-Fuller test
var adf = Rd("ADF$p.value");
if(adf > 0.6) enterLong();
if(adf < 0.6) exitLong();
plot("ADF p-value", adf ,NEW,RED); //display p-value
}
The optimize call is now right before the start of the R session.
Last edited by frutza; 11/19/25 22:33.
|
|
|
Re: Training with the R bridge does not work
[Re: frutza]
#488989
Yesterday at 22:07
Yesterday at 22:07
|
Joined: Jun 2023
Posts: 7
frutza
OP
Newbie
|
OP
Newbie
Joined: Jun 2023
Posts: 7
|
Well, I guess that's exactly what I tried to do in the first version of the code I posted here (see my very first post above): int size = optimize(50,10,100);
Rset("Data",rev(seriesC(),size),size); // send Close series to RIt makes complete sense to do it like that, but... it does not work. No training is happening. What am I missing here?
|
|
|
Re: Training with the R bridge does not work
[Re: AndrewAMD]
#488991
Yesterday at 22:32
Yesterday at 22:32
|
Joined: Jun 2023
Posts: 7
frutza
OP
Newbie
|
OP
Newbie
Joined: Jun 2023
Posts: 7
|
|
|
|
|