Indicator not updating
Created at 04 Nov 2013, 20:38
Indicator not updating
04 Nov 2013, 20:38
I wrote an indicator which does some calculations between two symbols' current bars (arbitrage based). When I run the indicator, values for the most recent 2-20 bars show up as NaN, although the past is showing up perfectly.
This code example shows an example of what I am trying to do:
private int GetIndexByDate(DateTime argDateTime) { for (int i = MarketSeries.Close.Count - 1; i > 0; i--) { if (argDateTime == MarketSeries.OpenTime[i]) return i; } return -1; } public override void Calculate(int index) { int SecondIndex = GetIndexByDate(MarketSeries.OpenTime[index]); if (SecondIndex != -1) { Result[index] = MarketSeries.Close[index] / SecondSeries.Close[SecondIndex]; } else { Result[index] = Result[index - 1]; } }
As you guys can see, I'm using the GetIndexByDate method to double check the both bars are matching open times, since I've found there are gaps in the data and the indices alone do not match up completely.
daemon
05 Nov 2013, 10:02
You need to fix your GetIndexByDate method.
It should be like this:
@daemon