private void btnCombine_Click(object sender, EventArgs e)
    {
      if (checkedListBox1.CheckedItems.Count == 0)
        return;

      List<Data.DatedDataCollection2> evals = new List<FX.Data.DatedDataCollection2>();
      Data.DatedDataCollection2 dateSet = null;

      foreach (int i in checkedListBox1.CheckedIndices)
      {
        ReturnsEval.DataSeriesEvaluator ev = (ReturnsEval.DataSeriesEvaluator)checkedListBox1.Items[i];

        Data.DatedDataCollection2 dd = new FX.Data.DatedDataCollection2(ev.Daily.Dates, ev.Daily.Data);

        evals.Add(dd);

        if (dateSet == null || dateSet.Length>dd.Length)
          dateSet = dd;
      }

      double[] returns = new double[dateSet.Length];

      for (int i = 0; i < dateSet.Length; ++i)
      {
        for (int j = 0; j < evals.Count; ++j)
        {
          returns[i]+=evals[j].ValueOnDate(dateSet.Dates[i]);
        }
      }

      ReturnsEval.DataSeriesEvaluator eval = new FX.ReturnsEval.DataSeriesEvaluator(dateSet.Dates, returns, "combined", FX.ReturnsEval.DataSeriesType.Returns);

      eval.Evaluate(eval.MinDate, eval.MaxDate);

      ReturnsEvalDisplay.ReturnsDisplay rd = new FX.ReturnsEvalDisplay.ReturnsDisplay();
      rd.Bind(eval);
      FX.Controls.ShowForm.Show(rd, FormBorderStyle.Sizable, null, "Combined p&l");
    }
    private void btnCombineWeights_Click(object sender, EventArgs e)
    {
      if (checkedListBox2.CheckedItems.Count == 0)
        return;

      List<WtsWrapper> list = new List<WtsWrapper>();

      for (int i = 0; i < checkedListBox2.CheckedIndices.Count; ++i)
        list.Add((WtsWrapper)checkedListBox2.Items[i]);

      Construct latestdateConstruct = null;
      for (int i = 0; i < list.Count; ++i)
        if (latestdateConstruct == null || (latestdateConstruct.Dates[0] < list[i].Weights.Dates[0]))
          latestdateConstruct = list[i].Weights;

      Construct combined = new Construct(latestdateConstruct.ArrayLength);
      combined.InitialiseToValue(latestdateConstruct.Dates, 0.0);

      foreach (DateTime date in latestdateConstruct.Dates)
        for (int i = 0; i < latestdateConstruct.ArrayLength; ++i)
          for (int j = 0; j < list.Count; ++j)
            combined.AddValue(date, i, list[j].Weights.GetValue(date, i));

      ReturnsEval.DataSeriesEvaluator eval = list[0].Trader.DoPnl(list[0].Args, combined);

      ReturnsEvalDisplay.ReturnsDisplay rd = new FX.ReturnsEvalDisplay.ReturnsDisplay();
      rd.Bind(eval);
      FX.Controls.ShowForm.Show(rd, FormBorderStyle.Sizable, null, "Combined weights");
    }