Price arrays in CBT

Hi,

I cannot seem to access any price arrays in the custom backtester except for the open positions and exit/entry price. Is it possible to access the full history and to reference the prices like in the basic backtester, if so, how?

You can access anything in custom backtest.
It really recommended to use existing documentation
http://www.amibroker.com/guide/a_custombacktest.html
and
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

Imagine someone spent HUNDREDS of hours writing these docs for you. The information is already there you just need to READ it.

If you want to use price arrays in the CBT, one way to do it is to pass them in using Static Variables.

// Regular AFL
StaticVarSet(Name() + "Close", Close);

// CBT
SetCustomBacktestProc("");
if (Status("action") == actionPortfolio)
{
  // Within a Trade Loop
  CloseArray = StaticVarGet(trade.Symbol + "Close");
  
  // Within a Signal Loop
  CloseArray = StaticVarGet(sig.Symbol + "Close");
}
1 Like

Or just Foreign() and/or SetForeign() for that matter

1 Like