Dear afl experts, I realize there are more than a few experts here have acknowledged in various posts that price arrays can be exposed inside the backtester; I also know that there is a Trade.GetPrice (i, “H”) c++ / afl member function inside the trade object. But try as I may, I could not get it to work, for example: here are the code snippets I used for testing:
/*
Other AFL code outside of backtester ....
*/
StaticVarSet ( name() + "High", High );
h_ = StaticVarGet ( name() + "High" );
_trace( "High outside of backtester: " + numtostr( h_[2], 1.2) );
/*
backtester code ....
*/
SetCustomBacktestProc("");
if ( Status("action") == actionPortfolio )
{
_trace( "High inside of backtester: " + numtostr(h_[2], 1.2));
// etc.,
}
Here is the debug window:
As can be seen in the picture, the entire price array disappear as soon as the code go pass the line "if (Status("action") == actionPortfolio)". Yes, I am fully aware I can use the Trade.GetPrice ( ) C++ member function object, but the reason for this post is because I have other custom arrays that make use of the price array data and are defined outside of the backtester, but I need to be able to reference these custom arrays inside the backtester, and these custom arrays make use of the price array, but the price array disappear inside the backtester. 1 reason for the use of these custom arrays is so that I can come up with a custom Van Tharp stop loss amount calculation that is based on price data (among other data) a few bars before the trade entry. Now here is my intuitive logic: if the price arrays can easily be seen inside the backtester, then there is no reason for the trade.GetPrice() member function, so somehow I think the price array when attached to a variable was passed by reference and the reference pointer that pointed to these price arrays goes out of the scope inside the backtester. Please help, I have been trying to figure this out for a while. Thanks.