Markus,
If all you want is a copy of the ~~~Equity that AmiBroker already
calculates for you, then there is no need to do any specialized signal/trade
handling.
Just do the following:
SetCustombacktestProc("");
if (Status("action") == actionPortfolio) {
bo =
GetBacktesterObject();
bo.Backtest();
AddToComposite(Foreign("~~~Equity", "C"), "~my_equity", "X", atcFlagDefaults | atcFlagEnableInPortfolio);
}
Plot(Foreign("~my_equity", "C"), "My
Equity", colorBlue, styleLine);
Mike
--- In amibroker@xxxxxxxxxps.com, "Markus Witzler"
<funnybiz@xxx> wrote:
>
> Hello,
>
> I want to
compute and plot my own equity (labeled my_equity).
>
> In the
code below (I skkipped the signal part with buy and sell signal), I wonder why
my_equity
>
> - is not being shown in backtester report
>
> - can´t be plotted
>
> - doesn´t show up in
exploration
>
> Why is that? If you reauire the rest of the code,
please let me know
>
> Thanks
>
> Markus
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
>
> ...<snip >...
>
> for
(trade = bo.GetFirstOpenPos(); trade; trade =
bo.GetNextOpenPos())
>
> {
>
> trade =
bo.findopenpos (sig.symbol);
>
> if (trade)
>
>
{
>
> value_all_open_pos=value_all_open_pos +
trade.GetPrice(i, "C") * trade.shares;
>
> }
>
>
>
> }
>
> bo.HandleStops(i); //
Process programmed stops or applystop at this bar
>
> my_equity
[i] = bo.cash + value_all_open_pos;
>
> } // End of for loop
over signals at this bar
>
>
> bo.UpdateStats(i, 1);
// Update MAE/MFE stats for bar
>
> bo.UpdateStats(i, 2); //
Update stats at bar's end
>
> } // End of for loop over
bars
>
> bo.PostProcess(); // Do post-processing
>
> AddToComposite(my_equity, "~~~my_equity","x",
atcFlagEnableInPortfolio | atcFlagDefaults);
>
>
}
>
> PlotForeign("~~~my_equity", "my_equity",
colorRed, styleHistogram );
>