/// <summary> /// VPIN indicator /// </summary> /// <returns></returns> public ZZVPINcdf ZZVPINcdf(Data.IDataSeries input, int sampleSize, int volBucketSize) { if (cacheZZVPINcdf != null) { for (int idx = 0; idx < cacheZZVPINcdf.Length; idx++) { if (cacheZZVPINcdf[idx].SampleSize == sampleSize && cacheZZVPINcdf[idx].VolBucketSize == volBucketSize && cacheZZVPINcdf[idx].EqualsInput(input)) { return(cacheZZVPINcdf[idx]); } } } lock (checkZZVPINcdf) { checkZZVPINcdf.SampleSize = sampleSize; sampleSize = checkZZVPINcdf.SampleSize; checkZZVPINcdf.VolBucketSize = volBucketSize; volBucketSize = checkZZVPINcdf.VolBucketSize; if (cacheZZVPINcdf != null) { for (int idx = 0; idx < cacheZZVPINcdf.Length; idx++) { if (cacheZZVPINcdf[idx].SampleSize == sampleSize && cacheZZVPINcdf[idx].VolBucketSize == volBucketSize && cacheZZVPINcdf[idx].EqualsInput(input)) { return(cacheZZVPINcdf[idx]); } } } ZZVPINcdf indicator = new ZZVPINcdf(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.SampleSize = sampleSize; indicator.VolBucketSize = volBucketSize; Indicators.Add(indicator); indicator.SetUp(); ZZVPINcdf[] tmp = new ZZVPINcdf[cacheZZVPINcdf == null ? 1 : cacheZZVPINcdf.Length + 1]; if (cacheZZVPINcdf != null) { cacheZZVPINcdf.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheZZVPINcdf = tmp; return(indicator); } }
/// <summary> /// VPIN indicator /// </summary> /// <returns></returns> public ZZVPINcdf ZZVPINcdf(Data.IDataSeries input, int sampleSize, int volBucketSize) { if (cacheZZVPINcdf != null) for (int idx = 0; idx < cacheZZVPINcdf.Length; idx++) if (cacheZZVPINcdf[idx].SampleSize == sampleSize && cacheZZVPINcdf[idx].VolBucketSize == volBucketSize && cacheZZVPINcdf[idx].EqualsInput(input)) return cacheZZVPINcdf[idx]; lock (checkZZVPINcdf) { checkZZVPINcdf.SampleSize = sampleSize; sampleSize = checkZZVPINcdf.SampleSize; checkZZVPINcdf.VolBucketSize = volBucketSize; volBucketSize = checkZZVPINcdf.VolBucketSize; if (cacheZZVPINcdf != null) for (int idx = 0; idx < cacheZZVPINcdf.Length; idx++) if (cacheZZVPINcdf[idx].SampleSize == sampleSize && cacheZZVPINcdf[idx].VolBucketSize == volBucketSize && cacheZZVPINcdf[idx].EqualsInput(input)) return cacheZZVPINcdf[idx]; ZZVPINcdf indicator = new ZZVPINcdf(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.SampleSize = sampleSize; indicator.VolBucketSize = volBucketSize; Indicators.Add(indicator); indicator.SetUp(); ZZVPINcdf[] tmp = new ZZVPINcdf[cacheZZVPINcdf == null ? 1 : cacheZZVPINcdf.Length + 1]; if (cacheZZVPINcdf != null) cacheZZVPINcdf.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheZZVPINcdf = tmp; return indicator; } }