Ejemplo n.º 1
0
 /// <summary>
 /// 销毁对象方法
 /// </summary>
 public virtual void Dispose()
 {
     if (!m_isDisposed)
     {
         if (m_chart != null)
         {
             m_chart.Dispose();
             m_chart = null;
         }
         if (m_dataSource != null)
         {
             m_dataSource.Dispose();
             m_dataSource = null;
         }
         if (m_latestDataCallBack != null)
         {
             m_quoteService.UnRegisterListener(m_qtRequestID, m_latestDataCallBack);
             m_latestDataCallBack = null;
         }
         if (m_securityFilterDataCallBack != null)
         {
             Stop();
             m_securityFilterService.UnRegisterListener(m_sfRequestID, m_securityFilterDataCallBack);
             m_securityFilterDataCallBack = null;
         }
         if (m_indicator != null)
         {
             m_indicator.Dispose();
             m_indicator = null;
         }
         m_isDisposed = true;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 宏运行中
 /// </summary>
 /// <param name="macro">宏</param>
 /// <returns>状态</returns>
 public virtual int OnMacroRunning(Macro macro)
 {
     if (OnMacroStart(macro) == 0)
     {
         return(0);
     }
     if (macro.m_script.Length > 0)
     {
         int        endIndex      = m_chart.Index;
         ChartA     ct            = m_chart.Chart;
         CTable     dataSource    = ct.DataSource;
         CTable     newDataSource = SecurityDataHelper.CreateDataSource(ct);
         int        interval      = macro.m_interval;
         CIndicator indicator     = SecurityDataHelper.CreateIndicator(ct, newDataSource, "", "");
         //indicator.AddFunction(new CFunctionEx(indicator, 1000, "ALERT", m_mainFrame-));
         //indicator.AddFunction(new CFunctionEx(indicator, 1001, "SETCYCLE", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1002, "SETLAYOUT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1003, "SETCODE", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1004, "SHOWWINDOW", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1005, "SLEEP", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1006, "SCROLLLEFT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1007, "SCROLLRIGHT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1008, "ZOOMIN", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1009, "ZOOMOUT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1010, "WIN_MOUSEEVENT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1011, "WIN_SETTEXT", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1012, "WIN_EXECUTE", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1013, "WIN_SENDKEY", m_chart));
         //indicator.AddFunction(new CFunctionEx(indicator, 1014, "WIN_GETVALUE", m_chart));
         indicator.Script = macro.m_script;
         int[] fields     = new int[] { KeyFields.CLOSE_INDEX, KeyFields.HIGH_INDEX, KeyFields.LOW_INDEX, KeyFields.OPEN_INDEX, KeyFields.VOL_INDEX, KeyFields.AMOUNT_INDEX };
         int   fieldsSize = fields.Length;
         int   startIndex = endIndex - (interval - 1);
         if (startIndex < 0)
         {
             startIndex = 0;
         }
         if (startIndex > endIndex)
         {
             startIndex = endIndex;
         }
         if (macro.m_type == 0 || macro.m_type == 2 || endIndex == -1)
         {
             double date = 0;
             newDataSource.Set(date, KeyFields.VOL_INDEX, 0);
             int index = newDataSource.GetRowIndex(date);
             for (int j = 0; j < fieldsSize; j++)
             {
                 if (fields[j] != KeyFields.VOL_INDEX)
                 {
                     newDataSource.Set2(index, fields[j], 0);
                 }
             }
         }
         else
         {
             for (int i = startIndex; i <= endIndex; i++)
             {
                 double date = dataSource.GetXValue(i);
                 newDataSource.Set(date, KeyFields.VOL_INDEX, dataSource.Get2(i, KeyFields.VOL_INDEX));
                 int index = newDataSource.GetRowIndex(date);
                 for (int j = 0; j < fieldsSize; j++)
                 {
                     if (fields[j] != KeyFields.VOL_INDEX)
                     {
                         newDataSource.Set2(index, fields[j], dataSource.Get2(i, fields[j]));
                     }
                 }
             }
         }
         if (macro.m_type == 1 || macro.m_type == 3)
         {
             indicator.OnCalculate(0);
         }
         else
         {
             for (int i = 0; i < interval; i++)
             {
                 indicator.OnCalculate(0);
             }
         }
         indicator.Clear();
         indicator.Dispose();
         newDataSource.Dispose();
     }
     OnMacroEnd(macro);
     return(1);
 }