In a traditional "bar-by-bar" backtest, all the arrays (often called series') 
grow in populated length one bar at a time during the process of the backtest.

In AB, all the arrays are fully and finally evaluated across the entire time 
period under test prior to the Backtester even looking at them.

That's the fundamental difference.  Understanding this and keeping it fully in 
mind is essential, IMO, for anyone who plans to write code in both AB and other 
platforms.

Using loop notion in AB is a means of getting "inside" array cells and altering 
them as of that point in the AFL.  Your AFL is still executed once (not on 
every bar), after which the Backtester goes to work (in the AA window) to 
evaluate the trading results of all those complete arrays you've 
calculated/populated in your AFL.

Important to note is that in realtime (i.e. indicator mode, on a chart), as new 
bars form, the whole shebang gets re-done with every new bar.  IOW, all your 
arrays are recalculated from scratch.  This is why it is very important when 
using AFL for realtime trading not to load more history than actually needed.

Above is my current high-level understanding, with which I'm able to code 
successfully in both AB and other platforms.  I hope what I've stated is 
literally correct, but if not, rephrasing or correction is invited.

Good luck!

--- In amibroker@yahoogroups.com, "jhnlmn" <jhn...@...> wrote:
>
> 
> 
> Hi,
> Thank you for your response
> 
> > In AmiBroker, the backtest itself is not a process that proceeds on a 
> > bar-by-bar basis.
> > At the detail level, the criteria necessary for a valid "bar-by-bar" 
> > backtest
> > and the criteria necessary for a valid "all-at-once" backtest (AmiBroker) 
> > are
> > not identical.
> 
> 
> I do not understand this.
> I was under impression (from the AB help) that operation on arrays all-at-once
> (like in "buy = cross(...)") can be rewritten using
> bar-by-bar technique, such as 
> for( i = 0; i < BarCount; i++ ) {... buy[i] = ...}
> 
> Personally, I found the loop code easier to understand and test,
> but it does not matter.
> It should not be any difference whether I am using TroughBar in a all-at-once
> operation, such as ValueWhen( TroughBars( s1, per, 1 ) == 0, x ,1)
> or in a loop like troughBars[i]. The value in array  troughBars at index X in 
> both cases
> should be the same, right? 
> 
> Then why are you saying that "AB's implementation of backtesting is different 
> than many other programs"?
> Where is the difference, other than in implementation of some indicators, 
> such as TroughBars?
> 
> Thank you
> John
>


Reply via email to