#property copyright "(c) Bernd Kreuss" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_width1 2 #include extern int maxbars = 300; extern int df = 20; int R; double buf_spline[]; int init(){ SetIndexBuffer(0, buf_spline); SetIndexStyle(0, DRAW_LINE); R = RInit("C:\\Program Files\\R\\R-2.12.1\\bin\\i386\\Rterm.exe --no-save", 2); Comment("maxbars="+maxbars+" df="+df); } int deinit(){ RDeinit(R); } int start(){ double hist[]; double pred[]; int i; if (RIsBusy(R)){ // last RExecuteAsync() is still not finished, do nothing. return(0); } if (RGetInteger(R, "as.integer(exists('model'))") == 1){ // there exists a model (the variable is set). // This means a previously started RExecuteAsync() has finished. // we can now predict from this model and plot it. ArrayResize(pred, maxbars); RGetVector(R, "rev(model$y)", pred, maxbars); for (i=0; i