Do I need to loop through monte carlo simulations to extract the values? If so, how would I do that? The Code below obviously doesn't work but hopefully will give you an idea of what I am trying to go for.
For example, we run 1000 simulations and I want to create a scatter plot of the total profit vs max drawdown. I am imagining something like
SetCustomBacktestProc("");
//Custom Metrics
if (Status("action")== actionPortfolio)
{
SetOption("UseCustomBacktestProc",True);
bo = GetBacktesterObject();
bo.Backtest();
SetOption("MCEnable",2);
SetOption("MCRuns",1000);
mc = bo.GetMonteCarloSim();
if (mc)
{
fh = fopen("C:\\Program Files\\AmiBroker\\TestOutputs\\Values.csv","a");
if (fh)
fputs("Net Profit,MaxDD\n",fh);
{
for (i = 0; i < GetOption("MCRuns"); i++)
nppct = mc.GetValue("NetProfitPercent",i);
maxdd = mc.GetValue("MaxSystemDrawdownPercent",i);
fputs(NumToStr(nppct) + "," + NumToStr(maxdd) +"\n",fh);
}
fclose(fh);
}
}
I am trying to generate something like;
so that in turn I can use excel or matplotlib to generate something like;
Alternately, am I simply making things difficult for myself and there is an easier way for me to do this inside AmiBroker without having to learn lowlevelgrtaphics etc?