internal void ProcessBuy(DateTime time, double bid, double ask, UnilateralTickCollection <DateTime> ticks) { KeyValuePair <DateTime, double>?whenTP = ticks.FirstEventWhenMoreOrEqual(time, ask + 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 minimum = ticks.FindMinimum(time, when.Key); minimum = ask - minimum; Spread += minimum; Spread2 += (minimum * minimum); }
internal void ProcessBuy(int time, double bid, double ask) { KeyValuePair <int, double>?whenTP = m_bids.FirstEventWhenMoreOrEqual(time, ask + TakeProfit); m_allCount++; if (null == whenTP) { //AP it will be more fair whenTP = m_bids.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 minimum = m_bids.FindMinimum(time, when.Key); minimum = ask - minimum; m_lossSum += minimum; m_lossSum2 += (minimum * minimum); } }
private void FindMinimumTest(DateTime from, DateTime to) { double control = double.PositiveInfinity; foreach (var element in m_items) { if ((element.Key >= from) && (element.Key <= to)) { if (control > element.Value) { control = element.Value; } } } double value = m_ticks.FindMinimum(from, to); if (value != control) { Assert.Fail("FindMinimum is failed"); } }