private void OnNotifyUpdate(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { try { Array data = (Array)pInstr.get_Get("Bid#,Ask#,NetPos,PL.Z,OpenPL^"); //get currency amount of tick double tickvalue = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "^")); for (int i = 0; i < data.Length; ++i) { if (data.GetValue(i) == null) { return; } } Update update = new Update(); update.Bid = Convert.ToDouble(data.GetValue(0)); update.Ask = Convert.ToDouble(data.GetValue(1)); update.NetPos = Convert.ToInt16(data.GetValue(2)); //convert number of ticks from PL to currency update.PL = tickvalue * Convert.ToDouble(data.GetValue(3)); update.OpenPL = Convert.ToDouble(data.GetValue(4)); update.Symbol = pInstr.Product; if (OnUpdate != null) { OnUpdate(this, new UpdateEventArgs(update)); } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error(ex.StackTrace); } } }
public void OnNotifyFound(XTAPI.TTInstrNotify pNotify, XTAPI.TTInstrObj pInstr) { try { //we use the same TTInstrNotify.OnNotifyFound event so we need to check the Product if (Convert.ToString(pInstr.get_Get("Product")) == instrument.Product) { tickPrice = Convert.ToDouble(pInstr.get_TickPrice(0, 1, "#")); tickIncr = Convert.ToInt16(pInstr.get_Get("TickIncrement")); } if (OnFound != null) { OnFound(this, new FoundEventArgs(tickPrice)); } Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }