private void FillMA(HistoricalData historicalData, PriceType type) { for (int i = 0; i < historicalData.Count; i++) { (MaDataSeries[0] as DataSeries <double, double>).GetHistoryValue(historicalData.GetValue(type, i), i); } }
private ICustomData <double, double> CreateAndFillMA(HistoricalData currentData, MAMode MAMode, int period, PriceType type, string name) { switch (MAMode) { case MAMode.SMA: MaDataSeries.Insert(0, new SMA(period, name)); break; case MAMode.EMA: MaDataSeries.Insert(0, new EMA(period, name)); break; case MAMode.SMMA: MaDataSeries.Insert(0, new SMMA(period, name)); break; case MAMode.LWMA: MaDataSeries.Insert(0, new LWMA(period, name)); break; } (MaDataSeries[0] as DataSeries <double, double>).GetHistoricalData(currentData); FillMA(currentData, type); MaDataSeries[0].GetValue(currentData.GetValue(type, 0)); return(MaDataSeries[0]); }
private ICustomData <double, double> CreateAndFillMA(HistoricalData currentData, MAMode MAMode, int period, PriceType type, string name) { this.AppendMa(currentData, MAMode, period, name); FillMA(currentData, type); BuiltInIndicatorDataSeries[0].GetValue(currentData.GetValue(type, 0)); return(BuiltInIndicatorDataSeries[0]); }
void SetDiff(int index1) { if (hd2 == null || hd1 == null) { return; } var time1 = hd1.GetTimeUtc(index1); var index2 = hd2.FindInterval(time1); if (index2 < 0) { return; } var open = hd1.GetValue(PriceType.Open, index1) - hd2.GetValue(PriceType.Open, index2); var close = hd1.GetValue(PriceType.Close, index1) - hd2.GetValue(PriceType.Close, index2); var high = hd1.GetValue(PriceType.High, index1) - hd2.GetValue(PriceType.High, index2); var low = hd1.GetValue(PriceType.Low, index1) - hd2.GetValue(PriceType.Low, index2); var min = Math.Min(open, close); var max = Math.Max(open, close); if (low > min) { low = min; } if (high < max) { high = max; } Lines["Open"].SetValue(open, index1); Lines["High"].SetValue(high, index1); Lines["Low"].SetValue(low, index1); Lines["Close"].SetValue(close, index1); }
public ICustomData <double, double> CreateOrUpdateMA(PriceType type, int period, MAMode mode, HistoricalData historicalData) { ICustomData <double, double> result; string name = mode.ToString() + period.ToString(); int findResult = BuiltInIndicatorDataSeries.FindIndex(x => x.Name == name); if (findResult != -1) { BuiltInIndicatorDataSeries[findResult].GetValue(historicalData.GetValue(type, 0)); result = BuiltInIndicatorDataSeries[findResult]; } else { result = CreateAndFillMA(historicalData, mode, period, type, name); } return(result); }