A rolling accumulation of volume based on Close price direction. More info ...
// usage
IEnumerable<ObvResult> results = Indicator.GetObv(history);
name | type | notes |
---|---|---|
history |
IEnumerable<Quote> | Historical Quotes data should be at any consistent frequency (day, hour, minute, etc). You must supply at least two historical quotes; however, since this is a trendline, more is recommended. |
IEnumerable<ObvResult>
The first period OBV will have 0
value since there's not enough data to calculate. We always return the same number of elements as there are in the historical quotes.
name | type | notes |
---|---|---|
Index |
int | Sequence of dates |
Date |
DateTime | Date |
Obv |
long | On-balance Volume |
Warning: absolute values in OBV are somewhat meaningless, so use with caution.
// fetch historical quotes from your favorite feed, in Quote format
IEnumerable<Quote> history = GetHistoryFromFeed("SPY");
// calculate
IEnumerable<ObvResult> results = Indicator.GetObv(history);
// use results as needed
DateTime evalDate = DateTime.Parse("12/31/2018");
ObvResult result = results.Where(x=>x.Date==evalDate).FirstOrDefault();
Console.WriteLine("OBV on {0} was {1}", result.Date, result.Obv);
OBV on 12/31/2018 was 539843504