Seer logo - advanced backtesting for stock, futures and forex trading systems using using technical analysis indicators, charts, money management and position sizing
Functions by Category Functions by Alphabetical list

RVar([name],[variable])
RVar(Column...Column)
RVar([name])

Usable in an seer event objectUsable in an seer indicator objectUsable in an seer chart object

This function passes data between Seer and the R environment. If R is not available in the current environment an error will be produced.

RVar has several different prototypes depending on how the function is used:
  • RVar([name]) If one item is passed and it's not a column the function will fetch data from R variable of item.
  • RVar([name],[variable]) If the function is passed two items and neither are columns, then the function will set the R variable name of item with the value of item two.
  • RVar(Column...Column) If the function is passed more than 2 items, they are assumed to be columns.
If any column is passed using RVar, a vector of the same size and name will be created within the R environment. If a vector is fetched from R and it matches the size of a column in the calling context, then a column will automatically be created.

Using Rvar doesn't change the scope or life of varables in either Seer or R.

Passing simple scalars to R:
RVar('five',5);
Sets the R variable five to the value 5. If the variable doesn't exist it will be created automatically
RVar('name','bob');
Sets the R variable name to the string bob. If the variable doesn't exist it will be created automatically

Returning simple scalars from R:
my $ans = RVar('five');
The variable $ans will contain the value of the R variable five. If the R variable does not exist undef will be returned.

Complex data types - Arrays and Vectors

A common R data type is the vector. Vectors can be passed to R from Seer as an array reference. Vectors will be returned from R as array references.

Passing an array (vector) to R:
RVar('x',[1,2,3,4,5,6,7]);
RVar('z', \ @mydata);
In the last example, the forward slash is used to create an reference to the array mydata.

Examples passing data to R:
#Pass the OHLCV columns from Seer to R. The columns will become R vectors of the same name.
RVar(Open,High,Low,Close,Volume);
Examples returning data to Seer:
#return the value of the R object sum to Seer
R 'sum <- 5 + 11';
my $ans = RVar('sum');

#Create an R vector abc
R 'abc <- c(1,2,3,4,5)';
#return the R vector as an array reference
my $abc = RVar('abc');

Related functions:

R

© 2011 seer trading systems ltd
feedback FAQ legal privacy