internal void ProcessSell(DateTime time, double bid, double ask, UnilateralTickCollection <DateTime> ticks) { KeyValuePair <DateTime, double>?whenTP = ticks.FirstEventWhenLessOrEqual(time, bid - m_tp); AllCount++; if (null == whenTP) { return; } Count++; KeyValuePair <DateTime, double> when = (KeyValuePair <DateTime, double>)whenTP; TimeSpan interval = when.Key - time; double hours = interval.TotalHours; Sum += hours; Sum2 += hours * hours; if (time == when.Key) { return; } double maximum = ticks.FindMaximum(time, when.Key); maximum = maximum - bid; Spread += maximum; Spread2 += (maximum * maximum); }
internal void ProcessSell(int time, double bid, double ask) { KeyValuePair <int, double>?whenTP = m_asks.FirstEventWhenLessOrEqual(time, bid - TakeProfit); m_allCount++; if (null == whenTP) { //AP it will be more fair whenTP = m_asks.LastTick; //return; } m_count++; KeyValuePair <int, double> when = (KeyValuePair <int, double>)whenTP; double interval = (when.Key - time) * this.TimeFactor; m_timeSum += interval; m_timeSum2 += interval * interval; if (time < when.Key) { double maximum = m_asks.FindMaximum(time, when.Key); maximum = maximum - bid; m_lossSum += maximum; m_lossSum2 += (maximum * maximum); } }
private void FindMaximumTest(DateTime from, DateTime to) { double control = double.NegativeInfinity; foreach (var element in m_items) { if ((element.Key >= from) && (element.Key <= to)) { if (control < element.Value) { control = element.Value; } } } double value = m_ticks.FindMaximum(from, to); if (value != control) { Assert.Fail("FindMaximum is failed"); } }