SetCustomBacktestProc("");
if
(Status("action") == actionPortfolio)
{
bo = GetBacktesterObject()
bo.Backtest();
mo = Month();
LastMonthC = bo.InitialEquity;
Count = 0;
////////////////////////////
// SKIP non-trading bars
////////////////////////////
for( i = 0; i < BarCount; i++ )
{
if( C[i] )
{
startbar = i;
break;
}
}
for( i = startbar + 1; i < BarCount; i++ )
{
if(mo[i] != mo[i-1])
{
Count++; //determine # of months in backtest
Chg = C / LastMonthC - 1; //get % chg for this month
VarSet("ChgMon" + NumToStr(Count,1.0), Chg); //save this month's % chg
LastMonthC = C[i]; //store this month's equity level to calculate % chg next month
}
}
for( i = 0; i < Count; i++ )
{
MoMed = ??? //determine median monthly return
AvgFive = ??? //determine average return of 5 worst months
}
MedRatio = MoMed / -AvgDD;
bo.AddCustomMetric("MedRatio", MedRatio);
}