Mike,
I have another simple question. The position sizing code looks as follows:
if (Status("action") == actionPortfolio) {
bo = GetBacktesterObject();
bo.PreProcess();
for (bar = 0; bar < BarCount; bar++) {
CurrentEquity = bo.Equity;
for (sig = bo.GetFirstSignal(bar); sig; sig =
bo.GetNextSignal(bar)) {
SetForeign(sig.Symbol);
RiskPerTrade = Ref(2 * ATR(10), -1);
NumberOfShares = AccountRiskPercent / RiskPerTrade[bar]
* CurrentEquity;
EntryPrice = sig.Price;
sig.PosSize = NumberOfShares[bar] * EntryPrice[bar];
RestorePriceArrays();
}
bo.ProcessTradeSignals(bar);
}
bo.PostProcess();
}
How do I show the RiskPerTrade for each trade in the backtest report? I tried
sig.AddCustomMetric("RiskPerTrade", RiskPerTrade) but the signal object doesn't
seem to
have the AddCustomMetric method. I also tried using the trade object as the
example in
the user manual, but I don't know how to let the trade object access the ATR
function,
which is necessary to calculate risk per trade.
Thanks,