I am attempting to gain access to the price bar in order to
make
calculations using open, close, etc. This is just a simplified
example
where I am trying to access the open and add it to
the
backtester/optimizer output. I am likely doing multiple things
wrong
with the code, but I am sure what. Any help would be
appreciated.
if(Status("action")== actionPortfolio)
{
bo =
GetBacktesterObject();
bo.preprocess();
for(bar=0;
bar<BarCount; bar++)
{
bo.processtradesignals(bar);
for(pos=
bo.getfirstopenpos(); pos; pos= bo.getnextopenpos())
{
price=
pos.getprice(bar,"o");
bo.addcustommetric("O",price);
}
}
bo.postprocess();
}
SetTradeDelays(
1, 1, 1, 1 );
PositionSize = MarginDeposit;
BuyPrice=
Open;
SellPrice= Open;
Buy= Cross(Signal(), MACD());
Sell=
Cross(MACD(), Signal());