protected override void chartSignal(Backtest.ProductBase product_, Controls.LineChartDataDisplay chart_) { chart_.ClearSeries(); chart_.AddSeries(product_.Prices, "Prices", 40, "##0.0##"); chart_.AddSeries(HelperMethods.GetRollingStat(product_.Prices, MA, Statistics.Average), "MA", 40, "##0.0##"); var series = product_.Prices; var rollingStdev = HelperMethods.GetRollingStat(product_.Prices.ToReturns(), 252, x => Statistics.Stdev(x)*Math.Sqrt(252d)); chart_.AddSeries(rollingStdev, "Stdev", 80, "##0.0#%"); chart_.AddSeries( HelperMethods.GetRollingStat(rollingStdev, 252, x => HelperMethods.GetPercentRank(x, x.Length - 1)), "Stdev_Pctile", 120, "0.00"); }
public override void Chart(Controls.LineChartDataDisplay lcdd_, Backtest.ProductBase product_) { var pxs = product_.Prices; lcdd_.ClearSeries(); lcdd_.AddSeries(pxs, string.Format("{0} price", product_.Name), 40, "##0.0##"); if (MA1.HasValue) lcdd_.AddSeries(HelperMethods.GetRollingStat(pxs, MA1.Value, Statistics.Average), string.Format("MA({0})", MA1), 40, "##0.0##"); if(MA2.HasValue) lcdd_.AddSeries(HelperMethods.GetRollingStat(pxs, MA2.Value, Statistics.Average), string.Format("MA({0})", MA2), 40, "##0.0##"); if (MA3.HasValue) lcdd_.AddSeries(HelperMethods.GetRollingStat(pxs, MA3.Value, Statistics.Average), string.Format("MA({0})", MA3), 40, "##0.0##"); }
protected override void chartSignal(Backtest.ProductBase product_, Controls.LineChartDataDisplay chart_) { var cumultRet = product_.Prices.ToReturns(product_.Convention).ToCumulative(); var ma1 = HelperMethods.GetMA(cumultRet, MA1); var ma2 = HelperMethods.GetMA(cumultRet, MA2); var ma3 = HelperMethods.GetMA(cumultRet, MA3); var ks = HelperMethods.GetRollingStat(cumultRet, KWindow, HelperMethods.GetK); chart_.ClearSeries(); chart_.AddSeries(cumultRet, "Prices", 40, "##0.0##"); chart_.AddSeries(ma1, string.Format("MA({0})", MA1), 40, "##0.0##"); chart_.AddSeries(ma2, string.Format("MA({0})", MA2), 40, "##0.0##"); chart_.AddSeries(ma3, string.Format("MA({0})", MA3), 40, "##0.0##"); chart_.AddSeries(ks, string.Format("K({0})", KWindow), 80, "##0.0"); }