Dear All

I have a price vector a which i defined as a = c(20,30,40,50)

I have an indicator signal sig which I define as sig = c(1,-1,1,-1) where 1
is long and -1 is short.

I am trying to calculate the rolling profit/loss and equity but unable to
do so because I do not understand the rolling concept using vectors.

I am able to calculate the final equity by the following function:

Amount*prod*(1+na.omit(Delt(a)*-1*sig))

which gives $375 as the final equity. I started off with $100.

Is there a function that can calculate the total profits in the interim
please? I know that by subscripting a and sig I can find out that easily
but that is not on a rolling basis. The problem is the current value of the
equity is a function of the previous values and hence I wish to know if
there are any vectorisable solutions please?

 Appreciate the kind help.

Many thanks
Raghu

	[[alternative HTML version deleted]]

