- ago
I notice that Sum.Series has been moved to the TimeSeries as the Sum method. I don't see an equivalent Sum.Value. Is it available??

I'm building an index in PreExecute and I want to use the Sum(period) of the bar (idx) in Execute. Currently I have to call MyIndex.Sum(period) in Execute to get the single value. For efficiency, I'd like to be able to get the single value.

This is what I'm doing now...
CODE:
      public override void Execute(BarHistory bars, int idx)       {          TimeSeries tsBasketSum = _tsBasket.Sum(_spPeriod.AsInt); //build entire TimeSeries          int bidx = tsBasketSum.IndexOf(bars.DateTimes[idx]);          _tsFundAvg[idx] = tsBasketSum[bidx];                    // Code for trading here.       }


I was hoping to do something like this...
CODE:
      public override void Execute(BarHistory bars, int idx)       {          int bidx = _tsBasket.IndexOf(bars.DateTimes[idx]);          _tsFundAvg[idx] = _tsBasket.Sum(_spPeriod.AsInt, bidx);          // Code for trading here.       }
0
797
2 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.32% )
- ago
#1
As you discovered, the Sum.Value method doesn't exist. As long as _tsBasket isn't changing, Value isn't required. Does the _tsBasket series change bar to bar?
0
- ago
#2
Yes, _tsBasket is a TimeSeries updated in PreExecute with an average of all participants ROC(Close,1) in that bar. I want to use the _tsBasket.Sum(x) in the Execute method for trading, so it has to be updated each call to get the latest values. Only the latest bar changed.
0

Reply

Bookmark

Sort