SetOption( "MCEnable", 2 ); // value == 2 forces MC to be enabled everywhere (in every mode including optimization - SLOW !) This Line is not working for me and I have the same problem. Optimization Report only displays with zero values for example bo.AddCustomMetric( "FinalEq99",mc.GetValue( "FinalEquity", 99 )); .
////////////////MonteCarloSim//////////////////////
/*
MonteCarloSim object has one function GetValue( "field", percentile ) that allows to access CDF values. Available "field" values are:
•"FinalEquity"
•"CAR"
•"LowestEquity"
•"MaxDrawdown"
•"MaxPercDrawdown"
Now here is the sample code that presents how to add 30th percentile FinalEquityand CAR to the report:
*/
SetOption( "MCEnable", 2 ); // value == 2 forces MC to be enabled everywhere (in every mode including optimization - SLOW !)
SetOption( "MCRuns", 1000 );
SetCustomBacktestProc( "" );
if( Status( "action" )== actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest(); // run default backtest procedure
// get access to Monte Carlo results
// note 1: it may be NULL if MC is NOT enabled
// note 2: MC results areavailable after Backtest() or PostProcess
// as MC simulation is donein final phase of post processing
mc = bo.GetMonteCarloSim();
//st = bo.GetPerformanceStats(0);
if( mc )
{
// get 99-th percentile of final equity and CAR etc distribution
bo.AddCustomMetric( "FinalEq99",mc.GetValue( "FinalEquity", 99 ));
bo.AddCustomMetric( "CAR99", mc.GetValue( "CAR", 99 ));
bo.AddCustomMetric( "MaxSysD%99", mc.GetValue( "MaxPercDrawdown", 99 ));
bo.AddCustomMetric( "CAR99/MDD99", mc.GetValue( "CAR", 99 )/ mc.GetValue( "MaxPercDrawdown" , 99 ));
}
}
I have the same problem. can any one help please. in the Backtest Report is OK , but in the Optimization Report only displays with zero values (0.00) see the image
That is correct. Drawdowns (MDD) are negative. CAR (if your system is profitable) is positve. In your own formula you divide positive number by negative and that will get you negative result. If you want positive number just use minus sign in your calculation to reverse sign.
If I use it from here as a general it will give null value just in the optimization not the backtest report so I tried just now to add it directly to every afl I use and then it worked great in the optimization.
thank you very much for your time and help.