public override void Reset() { // enable prompting of system parameters to user, // so they do not have to recompile to change things ParamPrompt.Popup(this, true, _black); Int32 numOfInterval = 1; BarInterval[] intervaltypes = new BarInterval[numOfInterval]; Int32[] intervalValues = new Int32[numOfInterval]; for (Int32 i = 0; i < numOfInterval; i++) { intervaltypes[i] = BarType; intervalValues[i] = NumItemPerBar; } _blt = new BarListTracker(intervalValues, intervaltypes); _blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); GenericParamUpdateHelper.updateParam(this, GenericParameter, false); Hashtable SMAInputParamTmp = new Hashtable(); SMAInputParamTmp["lookbackperiod"] = _barsback; SMAInputParamTmp["minmumsignallength"] = 1; _SMAFromATSGlobalIndicator = new ATSGlobalIndicatorPersonal.SMA(); _SMAFromATSGlobalIndicator.Param = SMAInputParamTmp; _SMAFromATSGlobalIndicator.Initializatin(); _isShutDown = false; TotalProfit = 0m; _pt.Clear(); }
public override void Reset() { // enable prompting of system parameters to user, // so they do not have to recompile to change things ParamPrompt.Popup(this, true, _black); Int32 numOfInterval = 1; BarInterval[] intervaltypes = new BarInterval[numOfInterval]; Int32[] intervalValues = new Int32[numOfInterval]; for (Int32 i = 0; i < numOfInterval; i++) { intervaltypes[i] = BarType; intervalValues[i] = NumItemPerBar; } _blt = new BarListTracker(intervalValues, intervaltypes); _blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); #region <在策略中实现从外部文件读取参数> //传递优化参数或系统参数 GenericParamUpdateHelper.updateParam(this, GenericParameter, false); if (File.Exists(SMAExternalParam)) { DataTable paramTableInput = null; StreamReader sr = new StreamReader(SMAExternalParam, Encoding.GetEncoding("GB18030")); paramTableInput = CsvParser.Parse(sr, true); sr.Close(); foreach (DataRow dr in paramTableInput.Rows) { if (paramTableInput.Columns.Contains("key") && paramTableInput.Columns.Contains("value")) { string tmpKey = dr["key"].ToString(); string tmpValue = dr["value"].ToString(); if (tmpKey == "genericparam") { GenericParameter = tmpValue; } //传递外部参数 GenericParamUpdateHelper.updateParam(this, GenericParameter, false); } } } #endregion Hashtable SMAInputParamTmp = new Hashtable(); SMAInputParamTmp["lookbackperiod"] = _barsback; SMAInputParamTmp["minmumsignallength"] = 1; _SMAFromATSGlobalIndicator = new ATSGlobalIndicatorPersonal.SMA(); _SMAFromATSGlobalIndicator.Param = SMAInputParamTmp; _SMAFromATSGlobalIndicator.Initializatin(); _isShutDown = false; TotalProfit = 0m; _pt.Clear(); }
public override void Reset() //对于新的一天来计算的时候要进行重置 { // enable prompting of system parameters to user, // so they do not have to recompile to change things ParamPrompt.Popup(this, true, _black); Int32 numOfInterval = 1; BarInterval[] intervaltypes = new BarInterval[numOfInterval]; Int32[] intervalValues = new Int32[numOfInterval]; for (Int32 i = 0; i < numOfInterval; i++) { intervaltypes[i] = BarType; intervalValues[i] = NumItemPerBar; } _blt = new BarListTracker(intervalValues, intervaltypes); _blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar); GenericParamUpdateHelper.updateParam(this, GenericParameter, false); Hashtable ShortSMAInputParamTmp = new Hashtable(); //对于SMA indicator进行更新,用今天重新计算的SMA,而不用昨天 Hashtable LongSMAInputParamTmp = new Hashtable(); ShortSMAInputParamTmp["lookbackperiod"] = _shortbarsback; LongSMAInputParamTmp["lookbackperiod"] = _shortbarsback + _incrementbarsback; ShortSMAInputParamTmp["minmumsignallength"] = _shortbarsback; LongSMAInputParamTmp["minmumsignallength"] = _shortbarsback + _incrementbarsback; _ShortSMAFromATSGlobalIndicator = new ATSGlobalIndicatorPersonal.SMA(); _LongSMAFromATSGlobalIndicator = new ATSGlobalIndicatorPersonal.SMA(); _ShortSMAFromATSGlobalIndicator.Param = ShortSMAInputParamTmp; _LongSMAFromATSGlobalIndicator.Param = LongSMAInputParamTmp; _ShortSMAFromATSGlobalIndicator.Initializatin(); _LongSMAFromATSGlobalIndicator.Initializatin(); // reset the parameters of ATR Hashtable ATRInputParamTmp = new Hashtable(); ATRInputParamTmp["lookbackperiod"] = _shortbarsback; ATRInputParamTmp["minmumsignallength"] = 14; _ATRFromATSGlobalIndicator = new ATSGlobalIndicatorPersonal.ATR(); _ATRFromATSGlobalIndicator.Param = ATRInputParamTmp; _ATRFromATSGlobalIndicator.Initializatin(); //--------------------------------------------------------- _isShutDown = false; TotalProfit = 0m; _pt.Clear(); if (_shortbarsback != 34 || _incrementbarsback != 84) { Console.WriteLine("yo hey"); } }