I wanted to follow up with the solution to this question for anyone else attempting to do this. The following code writes a custom report at the end of an optimization run that will give you additional information not presented in the main optimization results. This code uses two variables and pulls them directly from the system parameters.
Sub System_Example(Var1,Var2)
The other thing I realized is that it slows things down a lot when this additional info is calcualted so the following code only calculates this info after the last bar of the last market of each variable run. This can be pasted in at the very end of a system.
'CUSTOM OPTIMZAION REPORT
'Calculate and Store Data Dim objNoTrades As Integer Dim objWins As Integer Dim objGrossProfit As Double Dim objGrossLoss As Double Dim objMaxDD As Double Dim objWinBars As Integer Dim AvgWins As Double
If BarNumber=LastBar Then GValue1=Gvalue1+1 If Gvalue1=thisSession.MarketCount Then objNoTrades = thisSession.Summary.NoTrades objWins = thisSession.Summary.Wins objGrossProfit = thisSession.Summary.GrossProfit objGrossLoss = thisSession.Summary.GrossLoss objMaxDD = thisSession.Summary.MaxDrawDown objWinBars = thisSession.Summary.WinBars
If objWins > 0 Then AvgWins = objWinBars/objWins Else AvgWins = 0 End If 'Write Custom Report Dim CellRow As Integer Dim OptimizeCount As TSProcessor.ISession OptimizeCount=thisSession.OptimizeCount CellRow=OptimizeCount+2 SetTextValue("Variable 1",1,1,10) SetTextValue("Variable 2",1,2,10) SetTextValue("#Trades",1,3,10) SetTextValue("#Wins",1,4,10) SetTextValue("GrossProfit",1,5,10) SetTextValue("GrossLoss",1,6,10) SetTextValue("MaxDD",1,7,10) SetTextValue("WinDays",1,8,10)
SetTextValue(Var1,CellRow,1,10) SetTextValue(Var2,CellRow,2,10) SetTextValue(objNoTrades,CellRow,3,10) SetTextValue(objWins,CellRow,4,10) SetTextValue(objGrossProfit,CellRow,5,10) SetTextValue(objGrossLoss,CellRow,6,10) SetTextValue(objMaxDD,CellRow,7,10) SetTextValue(AvgWins,CellRow,8,10) Gvalue1=0 End If End If |