Hi All,

I wish I didn't have to ask as I have seen multiple similar python examples in other posts but i still cant seem to apply it to my own code.

I have a custom class containing multiple indicators. At OnData, I can only seem to access the current indicator values, e.g. stockDatas[0].CCI.Current. What I would like to do is access the previous CCI value for each security too. 

To do this I believe I need a rolling window. Below what I am trying to do is make a rolling window containing the stockDatas list. What I cant seem to figure out, is that the rolling window in the below code isnt functioning properly because calling in the debugger:
stockDatas[0].STC_RW[0].CCI.Current.Value and stockDatas[0].STC_RW[1].CCI.Current.Value, yeilds the same value consistently.

 

Edit:

Any help would be greatly appreciated, thanks!
 


namespace QuantConnect
{
public class cci_test2 : QCAlgorithm
{
private string my_secs = "EURUSD,AUDUSD,GBPUSD";
List<string> symbolList;
List<StockDataClass> stockDatas = new List<StockDataClass>();

public override void Initialize()
{
SetStartDate(2012, 1, 1);
SetEndDate(2015, 1, 1);
SetCash(10000);

symbolList = new List<string>(my_secs.Split(new char[] { ',' }));
foreach (string ticker in symbolList)
{
AddSecurity(SecurityType.Forex, ticker, Resolution.Hour,true,50.0m,false);
StockDataClass stockData = new StockDataClass(ticker);
stockData.CCI = CCI(ticker, 20, MovingAverageType.Simple, Resolution.Hour);
stockData.ATR = ATR(ticker, 20, MovingAverageType.Simple, Resolution.Hour);
stockData.STC_RW = new RollingWindow<StockDataClass>(2);
stockDatas.Add(stockData);
}
}

public void OnData(TradeBars data)
{
for (int i = 0; i < stockDatas.Count; i++)
{
//This is where I am attempting to add the bars stockdata indicator values to a rolloing window.
stockDatas[i].STC_RW.Add(stockDatas[i]);
SetHoldings("EURUSD", 5);
}
}

}

class StockDataClass
{
public StockDataClass(string ticker)
{
Ticker = ticker;
}
public string Ticker;

public CommodityChannelIndex CCI;
public AverageTrueRange ATR;

public RollingWindow<StockDataClass> STC_RW;

}

}