... in the portfolio backtest phase, current symbol is the ~~~EQUITY, and its very first bar is the bar the "From" date.
The symbol you are working with (DIFFERENT than Equity) may and usually will start way earier.
If you use SetForeign/Foreign it always synchronizes data to current equity
- it is described in the User's Guide (see Foreign function docs).
So in portfolio backtester, if you do SetForeign() your original symbol data will start from "FROM" date.
Now if you happen to use ATR in the very first nATRPeriod period bars, the ATR will not be available.
What is the lesson learned?
1. Assume your own errors.
2. If you need some value from the FIRST backtest phase in the custom backtester, use static variables
to store any values you need in the first phase and read them in custom backtester.
It is easier and way way faster to execute.
Code: Select all
StaticVarSet("MyAtr"+Name(), ATR( nATRPeriod ) );
if( Status("action") == actionPortfolio )
bo = GetBacktesterObject();
for (trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade())
strSymbol = trade.Symbol;
fEntryDateTime = trade.EntryDateTime;
fATR = Lookup( StaticVarGet("MyAtr"+ strSymbol ), fEntryDateTime);
Topics about the AmiBroker platform
1 post • Page 1 of 1
- Posts: 948
- Joined: Thu Jul 26, 2007 7:20 pm
Regarding a scenario where a user wanted to have an ATR value available in the custom-backtest phase, but found that it was not ready as of the From Date, TJ writes in the AB Yahoo Group : (bold emphasis mine)
Users browsing this forum: No registered users and 1 guest