Posted By: gtell
Baroffset - 04/14/18 13:38
Can we use different Baroffset inside the same run() function?
The following code does not seems to work.
It basically export the same timeseries.
The following code does not seems to work.
It basically export the same timeseries.
Code:
#include <r.h> #define W 32 #define BUFFER 64 function run() { StartDate = 20120115; BarPeriod = 60; LookBack = 100; MaxBars = 1000; int i=0; set(RULES); Spread = RollLong = RollShort = Commission = Slippage = 0; int Offset = ifelse(Train,1,0); BarOffset=59; vars Close59 = series(priceClose()); BarOffset=0; vars Close0 = series(priceClose()); var Signals[BUFFER]; int index=0; for (i=(W-(1-Offset));i>=Offset;i--) { Signals[index] = Close0[i]; index++;} for (i=(W-(1-Offset));i>=Offset;i--) { Signals[index] = Close59[i]; index++;} var Prediction = adviseLong(SIGNALS,0,Signals,BUFFER); if(Prediction > 0.0) enterLong(); if(Prediction < 0.0) enterShort(); }