protected void calculateCurrentOpen(Series <DateTime, MarketDataElement> series) { if (currentOpenPrice != 0) { return; } MarketDataElement lastItem = (MarketDataElement)series.GetAt(series.KeyCount - 1); MarketDataElement openItem = MarketDateElementHelper.getFirstAvaMarketData(series, MarketDataUtil.getStartTime(lastItem.time)); currentOpenPrice = openItem.open; log.Info("[calculateCurrentOpen] : currentOpen = " + currentOpenPrice); }
public static List <SARRow> addFirstRow(Series <DateTime, MarketDataElement> series, int period, DateTime startTime, double af, double max_af) { List <SARRow> resultRow = new List <SARRow>(); MarketDataElement lastData = series.GetAt(series.KeyCount - 1); Series <DateTime, MarketDataElement> lastNData = MarketDateElementHelper.getLastNMarketData(series, period); List <MarketDataElement> lstData = lastNData.Values.ToList(); SARRow row = new SARRow(); foreach (MarketDataElement data in lstData) { if (row.sarValue == 0) { row.sarValue = Math.Min(data.open, data.close); } else { row.sarValue = Math.Min(row.sarValue, Math.Min(data.open, data.close)); } if (row.extremePoint == 0) { row.extremePoint = Math.Max(data.open, data.close); } else { row.extremePoint = Math.Max(row.extremePoint, Math.Max(data.open, data.close)); } } if (Math.Min(lastData.open, lastData.close) > row.sarValue) { row.direction = 1; } else { row.direction = -1; } row.delta_EP_SAR = row.extremePoint - row.sarValue; row.accFactor = af; row.product_af_delta = row.accFactor * row.delta_EP_SAR; row.time = lastData.time; resultRow.Add(row); return(resultRow); }
public static double findEnterPtTriggerMomentum(List <CMRow> rows, Series <DateTime, MarketDataElement> series, int period, DateTime startTime, double delta, String buySell) { Series <DateTime, MarketDataElement> lastNData = MarketDateElementHelper.getLastNMarketData(series, period - 1); MarketDataElement firstData = MarketDateElementHelper.getFirstAvaMarketData(lastNData, startTime); MarketDataElement lastData = series.GetAt(series.KeyCount - 1); //log.Info("firstData.open : " + firstData.open); double open = firstData.open; if (AppConstant.BUY_SIGNAL.Equals(buySell)) { return(open + delta); } else { return(open - delta); } }
public static List <CMRow> calculate(List <CMRow> rows, Series <DateTime, MarketDataElement> series, int period, DateTime startTime) { Series <DateTime, MarketDataElement> lastNData = MarketDateElementHelper.getLastNMarketData(series, period); MarketDataElement firstData = MarketDateElementHelper.getFirstAvaMarketData(lastNData, startTime); MarketDataElement lastData = series.GetAt(series.KeyCount - 1); double open = firstData.open; double close = lastData.close; double delta = Math.Abs(close - open); CMRow row = new CMRow(); row.startTime = firstData.time; row.startPt = firstData.open; row.endTime = lastData.time; row.endPt = lastData.close; row.deltaPt = delta; rows.Add(row); return(rows); }