1
Reply

Finding Maximum Profit

Ask a question
bengof Gof

bengof Gof

14 years ago
2.3k
1

I am writing an application where I need to test for 7 parameters.  Each parameter has a range which will generate about 2600 possibilities for each value being evaluated.  The total number of rows generated when the test is complete would be about 50GB of data stored on SQL Server.   I am using a "FOR " Loop to test for each value of each parameter.  The problem is it takes a long time to complete the test.  I am wondering if anyone knows a better way to do this.  I have been thinking to do it on SQL server using stored procedures but some of the calculations are some what more complex which I need to do it in C#.  here is a snippet of what I am doing:
 
MA_TypeArrayList =
new ArrayList();
MA_TypeArrayList.Add(
"TA_MAType_EMA");
MA_TypeArrayList.Add(
"TA_MAType_SMA");
MA_TypeArrayList.Add(
"TA_MAType_WMA");
...............................
MA_SeriesArrayList =
new ArrayList();
MA_SeriesArrayList.Add(
"HLC3");
MA_SeriesArrayList.Add(
"CLOSE");
.....................................................
foreach (string strMA1Type in MA_TypeArrayList)
{
   cboMA1Type.Text = strMA1Type;
   foreach (string strMA1Series in MA_SeriesArrayList)
   {
      cboSeriesType1.Text = strMA1Series;
      RunTest();
      if (dblProfitLoss > dblHighestProfit)
      {
         dblHighestProfit = dblProfitLoss;
         strBestValues =
"Optimal MA1 Value = " + x.ToString() +
                              " Optimal MA1 Type = " + strMA1Type.ToString() +
                                " Optimal MA1 Series = " + strMA1Series.ToString() +
                                 " Optimal MA2 Value = " + y.ToString() +
                                   " Optimal MA2 Shift Value = " + z.ToString() +
                                       " Max Profit = " + dblHighestProfit.ToString();
   }

}
 
Thanks in advance.
 
Ben G
 
 
 
 
}

Answers (1)