/// <summary> /// Fired when the CQGCurves item is updated. /// </summary> /// <param name="cqg_custom_study"> /// Reference to changed CQGCustomStudy /// </param> /// <param name="index_"> /// Specifies the updated CQGCurves index. /// </param> private void CEL_CustomStudyUpdated(CQGCustomStudy cqg_custom_study, int index_) { try { // try get the set KaiTrade.Interfaces.ITSSet mySet; if (m_TSSets.ContainsKey(cqg_custom_study.Id)) { mySet = m_TSSets[cqg_custom_study.Id]; if (!mySet.ReportAll) { // they only want added bars - so exit return; } CQGCurves myCurves = cqg_custom_study[index_]; mySet.TimeStamp = myCurves.Timestamp; for (int j = 0; j <= myCurves.Count - 1; j++) { //myItem.SetCurveValue(cqg_expression.OutputHeaders[j], double.Parse(expressionOutputs[j].ToString())); mySet.SetUDCurveValue(j, double.Parse(myCurves[j].ToString())); mySet.SetUDCurveName(j, cqg_custom_study.CurveHeaders[j].ToString()); } mySet.Updated = true; } } catch (Exception myE) { log.Error("CEL_CustomStudyUpdated", myE); } }
/// <summary> /// Fired when a CQGCurves item is added to the end of CQGCustomStudy. /// </summary> /// <param name="cqg_custom_study"> /// Reference to changed CQGCustomStudy. /// </param> private void CEL_CustomStudyAdded(CQGCustomStudy cqg_custom_study) { try { // try get the set KaiTrade.Interfaces.ITSSet mySet; if (m_TSSets.ContainsKey(cqg_custom_study.Id)) { mySet = m_TSSets[cqg_custom_study.Id]; mySet.Items.Clear(); if (cqg_custom_study.Status == eRequestStatus.rsSuccess) { // Clears all records mySet.Items.Clear(); if (cqg_custom_study.Count == 0) { return; } for (int i = 0; i < cqg_custom_study.Count; i++) { // get a new TS item KaiTrade.Interfaces.ITSItem myItem = mySet.GetNewItem(); myItem.Index = i; myItem.TimeStamp = cqg_custom_study[i].Timestamp; myItem.ConditionName = mySet.ConditionName; CQGCurves myCurves = cqg_custom_study[i]; for (int j = 0; j <= myCurves.Count - 1; j++) { myItem.SetCurveValue(cqg_custom_study.CurveHeaders[j], double.Parse(myCurves[j].ToString())); } mySet.AddItem(myItem); } mySet.Added = true; } else { mySet.Text = cqg_custom_study.LastError.Description; } } } catch (Exception myE) { log.Error("CEL_CustomStudyAdded", myE); } }
/// <summary> /// This event is fired when the custom study (CQGCustomStudy) is resolved /// or when some error has occurred during the custom studies request processing. /// </summary> /// <param name="cqg_custom_study"> /// Reference to resolved CQGCustomStudy. /// </param> /// <param name="cqg_error"> /// The CQGError object that describes the last error occurred /// while processing the CustomStudy request or /// Nothing/Invalid_Error in case of no error. /// </param> private void CEL_CustomStudyResolved(CQGCustomStudy cqg_custom_study, CQGError cqg_error) { try { lock (m_CustomStudyToken1) { try { driverLog.Info("CEL_CustomStudyResolved:" + cqg_custom_study.Id); // try get the set KaiTrade.Interfaces.ITSSet mySet; if (m_TSSets.ContainsKey(cqg_custom_study.Id)) { mySet = m_TSSets[cqg_custom_study.Id]; if (cqg_custom_study.Status == eRequestStatus.rsSuccess) { // Clears all records mySet.Items.Clear(); mySet.Status = KaiTrade.Interfaces.Status.open; if (cqg_custom_study.Count == 0) { return; } for (int i = 0; i < cqg_custom_study.Count; i++) { // get a new TS item KaiTrade.Interfaces.ITSItem myItem = mySet.GetNewItem(); myItem.Index = i; myItem.TimeStamp = cqg_custom_study[i].Timestamp; myItem.ConditionName = mySet.ConditionName; CQGCurves myCurves = cqg_custom_study[i]; for (int j = 0; j <= myCurves.Count - 1; j++) { myItem.SetCurveValue(cqg_custom_study.CurveHeaders[j], double.Parse(myCurves[j].ToString())); } mySet.AddItem(myItem); } mySet.Added = true; } else { mySet.Text = cqg_error.Description; mySet.Status = KaiTrade.Interfaces.Status.error; this.SendStatusMessage(KaiTrade.Interfaces.Status.open, "CEL_CustomStudyResolved" + mySet.Text); } } else { driverLog.Info("CEL_CustomStudyResolved:TSData not found"); } } catch (Exception myE) { log.Error("CEL_CustomStudyResolved", myE); } } } catch { } }